在 webkit 浏览器中 $(document).ready 之后加载的图像'刷新
我有一个情况,似乎 $(document).ready 的内容在页面实际加载之前正在执行。当页面在 WEBKIT 浏览器中刷新时,就会发生这种情况。这是怎么回事?
它扰乱了我的 offset() 计算,因为计算是在应用所有 CSS 之前进行的。
I have a case where it seems that the contents of $(document).ready are being executed before the page is actually loaded. This happens when the page is REFRESHED in WEBKIT browsers. What's going on with that?
It's messing with my offset() calculations because the calculation is made before all of the CSS is applied.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我在刷新页面时也遇到过类似的问题(尤其是使用 Chrome),并且我发现只需将 CSS 链接移到脚本上方,使其首先加载,就可以解决所有问题。
I've had similar problems with refreshing a page (especially with Chrome), and I've found that by simply moving the CSS link above the script, so that it loads first, resolved all issues.
如果您正在处理图像,
$(document).ready
可能会在图像完全加载之前开始执行...如果是这种情况,请使用$(window).load
反而!If you are processing images,
$(document).ready
may start executing before the images are fully loaded...if this is the case use$(window).load
instead!$(document).ready()
在 DOM 完全加载时被调用。现在,这并不一定意味着您的页面已完全加载 - 例如,CSS 中的背景图像可能仍在加载。$(document).ready()
is invoked when the DOM is fully loaded. Now that doesn't necessarily mean your page is fully loaded - e.g. background images in the CSS may still be loading.