1,onload事件
[url=http://i3.sinaimg.cn/rny/webface/login/css/login101021_min.css]</HEAD>
<BODY>
</BODY>
</HTML>
IE6/7 :
[img]http://files.jb51.net/upload/201104/20110427000813547.png[/img]
IE8/9 :
[img]http://files.jb51.net/upload/201104/20110427000813571.png[/img]
Opera :
[img]http://files.jb51.net/upload/201104/20110427000813183.png[/img]
即IE6/7/8/9/Opera都支持onload事件, Firefox/Safari/Chrome不支持。
注:用JS创建link标签再添加到head中,情况如上。
2,onreadystatechange事件
<!DOCTYPE HTML>
<HTML>
<HEAD>
<meta charset="utf-8" />
<title>Link Element onreadystatechange</title>
<link type="text/css" rel="stylesheet" href="http://i3.sinaimg.cn/rny/webface/login/css/login101021_min.css" onreadystatechange="alert(this)"/>
</HEAD>
<BODY>
</BODY>
</HTML>
IE6/7/8/9中弹出了两次,其它浏览器均没有弹。说明只有IE支持link元素的onreadystatechange事件。弹出两次分别是readyState为loading,complete状态。可使用readyState来判断载入情况。我们再使用JS动态创建link元素试试,
[url=https://developer.mozilla.org/en/HTML/Element/link]https://developer.mozilla.org/en/HTML/Element/link[/url]
[url=http://msdn.microsoft.com/en-us/library/ms535848%28v=VS.85%29.aspx]http://msdn.microsoft.com/en-us/library/ms535848%28v=VS.85%29.aspx[/url]
[url=http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-35143001]http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-35143001[/url]