【问题标题】:Load respond.js after page load页面加载后加载 respond.js
【发布时间】:2014-08-12 19:31:53
【问题描述】:

有没有办法在页面完全加载后加载respond.js,之后是否需要调用来激活它?

我的问题是我无法编辑网络应用程序的结构,我只能操作“皮肤文件”(包括 css 和 js 文件)。

我可以将它包含在 js 文件中,但是情况是 js 文件是在皮肤 css 文件之前加载的,而当我阅读到 response.js 时,它需要在样式表之后加载才能工作。

这是响应式设计在 IE8 中工作所必需的。

任何帮助或建议都会很棒。

结构是这样的:

<head>
/*bunch of jquery scripts*/
/*skin js file with the respond.js file linked*/
/*skin css file*/
</head>
<body>
</body>

【问题讨论】:

  • 尝试使用setTimeout() method
  • 是对 HTML 页面顶部的 css 文件的调用和对底部的 js 文件的调用(&lt;/body&gt; 之前)?这应该确保首先加载 css 文件。
  • 结构如下 /*一堆 jquery 脚本*/ /*skin js 文件和respond.js 文件链接*/ /*skin css 文件*/

标签: javascript jquery html css respond.js


【解决方案1】:

如果您使用的是 jquery,则可以这样做。

$(window).bind("load", function() {
   var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = 'path to ur js file';
    document.head.appendChild(script);
});

希望这会对你有所帮助。

【讨论】:

  • 谢谢,这已经完成了我需要的事情。它在所有其他文件之后添加了 js 文件,并稍加修改 document.getElementsByTagName('head')[0].appendChild(script);,因为 IEdocument.head。遗憾的是,这并没有解决我的问题,respond.js 脚本对我不起作用。谢谢@madhurjya
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-05-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多