获取标签的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属性兼容性的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PostgreSQL SystemTap
- 下一篇: 信息安全系统设计基础第一周学习总结