attachevent和addeventlistener区别及浏览器是火狐还是ie(The difference between attachevent and addeventlistener and browser is Firefox or IE).docVIP
- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
attachevent和addeventlistener区别及浏览器是火狐还是ie(The difference between attachevent and addeventlistener and browser is Firefox or IE)
attachevent和addeventlistener区别及浏览器是火狐还是ie(The difference between attachevent and addeventlistener and browser is Firefox or IE)
Is it Firefox or IE that uses attachEvent and addEventListener to distinguish browsers?
The navigator.userAgent string was used before to determine the browser type
Switch (navigator.userAgent.toLowerCase ().IndexOf (MSIE)) //firefox|opera|safari|msie
{
Case (-1):
Alert (DOM browser);
Default:
Alert (IE browser);
}
In an article read today, users can change userAgent in some browsers, so you cant just use this method to check your browser.
In practice, the most common check is the difference between a IE browser and a standard DOM browser, so you can use window.addEventListener to determine the two types of browsers
If (typeof window.addEventListener=== function)
{
Alert (DOM browser);
}
Else
{
Alert (IE);
}
Expert written in a browser testing code
Var = isIE (window.attachEvent window.opera!!!);
VaR, isOpera =!! window.opera;
Var isSafari = navigator.userAgent.indexOf (` AppleWebKit/ ) -1;
Var isMoz = navigator.userAgent.indexOf (Gecko) -1 navigator.userAgent.indexOf (KHTML) = -1;
Var isMobileSafari = = navigator.userAgent.match (/Apple.*Mobile.*Safari/);
Var = isIE5 (navigator.appVersion.indexOf (MSIE 5) 0 (navigator.appVersion.indexOf) || (MSIE) 0 and parseInt (navigator.appVersion) 4);
Var isIE55 = (navigator.appVersion.indexOf (MSIE 5.5 ) 0);
Var isIE6 = (navigator.appVersion.indexOf (MSIE 6 ) 0);
Var isIE7 = (navigator.appVersion.indexOf (MSIE 7 ) 0);
Var isIE8 = (navigator.appVersion.indexOf (MSIE 8 ) 0);
The attachEvent method adds additional processing events to an event. (do not support Mozilla Series)
The addEventListener method is used in the Mozilla series
Document.getElementById (BTN).Onclick = method1;
Document.getElementById (BTN).Onclick = method2;
Document.getElementById (BTN).Onclick = method3;
Java code
If (window.addEventListener)
{
Window.addEventListener (load, _uCO, false);
}
Else if (window.attachEvent)
{
Win
您可能关注的文档
- 23-国家卫生统计网络直报系统操作指南(23- National Health Statistics network direct reporting system operation manual).doc
- 23《假如》第一课时(23 if the first class hour).doc
- 21-24个月婴儿智力促进方案(21-24 month infant intelligence program).doc
- 24《东方之珠》教学设计之四(24 teaching design of Pearl of the Orient four).doc
- 24层魔塔攻略(24 layer tower Raiders).doc
- 24小时防晒策略(24 hours Sun Protection Strategy).doc
- 24招电动车促销方案集锦(24 strokes electric vehicle sales program highlights).doc
- 24节气的含义及来历(The meaning and origin of the 24 solar terms).doc
- 24节气歌(24 solar terms).doc
- 25 古诗两首(25 ancient poems two).doc
- 贵州贵州省建设投资集团有限公司招聘考试真题附答案详解(研优卷).docx
- 河南南阳师范学院2021年招聘25名硕士研究生冲刺卷一(附答案与详解)及答案详解(名校卷).docx
- 陕西延长石油 (集团) 有限责任公司 所属单位招聘笔试题库及答案详解(必刷).docx
- 贵州民航产业集团有限公司招聘笔试题库含答案详解(基础题).docx
- 广汉市2025年公开招聘社区专职工作者(125人)考试备考题库含答案详解(考试直接用).docx
- 邢台市水务发展集团有限公司招聘真题附答案详解(实用).docx
- 新华保险总部人力资源部(党委组织部)招聘笔试题库含答案详解(预热题).docx
- 贵州苔茶产业发展集团有限公司招聘笔试题库含答案详解(b卷).docx
- 广汉市2025年公开招聘社区专职工作者(125人)考试备考题库附答案详解(综合题).docx
- 贵州城乡产业发展集团有限公司招聘笔试题库附答案详解(实用).docx
文档评论(0)