本文介绍了HTML背景图像OnLoad的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个简单的HTML页面,里面有一点JavaScript。 JavaScript在主体中启动onLoad。身体也有一个背景图像。 JavaScript在加载背景图像之前启动。
I have a simple HTML page with a little JavaScript in it. The JavaScript launches onLoad in the body. The body also has a background image. The JavaScript launches before the background image is loaded. Is there a way to have the body onLoad wait for the body background image to load?
<body background="http://xxx.com/xxx.jpeg" id="myBody" onload="pageLoaded()">
推荐答案
如果您想确保脚本启动完毕图像已被加载,然后使用
If you want to make sure a script launches after all the images have been loaded, then use
$(window).load(function() {
//.......................
});
这个事件只会在所有脚本,css,js, $(document).ready();
This event, will only fire once all the scripts, css, js, images have been load, unlike $(document).ready();
这篇关于HTML背景图像OnLoad的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!