文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>script的onerror事件支持情况调查

script的onerror事件支持情况调查

时间:2011-02-12  来源:司徒正美

var el = document.createElement("script"); document.body.insertBefore(el,null); var name = "onerror" alert(name in el); el.setAttribute(name,""); alert(typeof el[name] === "function"); el.onerror = function(){ alert("支持onerror事件") } el.src = "test_"+1*new Date; setTimeout(function(){ var parent = el.parentNode if(parent && parent.nodeType === 1){ if (el.clearAttributes) { el.clearAttributes(); } else { el.onerror = null; } parent.removeChild(el) el = name = null; } },2000)

运行代码

看到没有IE678与opera就是一对活宝,真想砍死opera那帮人!

现在只能用这代码进行区分了:

//by 司徒正美
var supportScriptError = (!window.opera) && -[1,];

相关链接:检测浏览器对事件的支持程度

相关阅读 更多 +
排行榜 更多 +
<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />

<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />

飞行射击 下载
<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />

<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />

飞行射击 下载
<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />

<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />

飞行射击 下载