日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

获取标签的src属性兼容性

發布時間:2025/3/20 70 豆豆
生活随笔 收集整理的這篇文章主要介紹了 获取标签的src属性兼容性 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

獲取節點如script標簽的src屬性時,針對非IE6,IE7可以直接使用src屬性,但在IE6-7中存在問題,可以借助getAttribute方法

getAttribute(attr,iflag)

iflag 取值:

0: 屬性不區分大小寫,但是返回一個被修改的值

1:區分大小寫,必須嚴格和屬性名匹配才能查找到

2:返回一個字符串,但是針對事件屬性不適用

4:返回一個擴展的url,完整的url值,只針對url屬性有效

?

官方文檔:https://msdn.microsoft.com/en-us/library/ms536429(VS.85).aspx

0

Default. Performs a property search that is not case-sensitive, and returns an interpolated value if the property is found.

1

Performs a case-sensitive property search. To find a match, the uppercase and lowercase letters instrAttributeName?must exactly match those in the attribute name.

2

Returns attribute value as a?String. This flag does not work for event properties.

4

Returns attribute value as a fully expanded URL. Only works for URL attributes.

?

兼容的寫法:

function getScriptAbsoluteSrc(node) { return node.hasAttribute ? // non-IE6/7 node.src : // see http://msdn.microsoft.com/en-us/library/ms536429(VS.85).aspx node.getAttribute("src", 4) }

?

轉載于:https://www.cnblogs.com/lydialee/p/4817437.html

總結

以上是生活随笔為你收集整理的获取标签的src属性兼容性的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。