日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

获取标签的src属性兼容性

發布時間:2025/3/20 编程问答 52 豆豆
生活随笔 收集整理的這篇文章主要介紹了 获取标签的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属性兼容性的全部內容,希望文章能夠幫你解決所遇到的問題。

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