• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com专业计算机教程网站
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • html/xhtml
  • html5
  • CSS
  • XML/XSLT
  • Dreamweaver教程
  • Frontpage教程
  • 心得技巧
  • bootstrap
  • vue
  • AngularJS
  • HBuilder教程
  • css3
  • 浏览器兼容
  • div/css
  • 网页编辑器
  • axure
您的位置:首页 > 网页设计 >html/xhtml > 英文:A链接标记ie下会自动补全href

英文:A链接标记ie下会自动补全href

作者:佚名 字体:[增加 减小] 来源:互联网 时间:2017-08-05

本文主要包含自动,标记,链接,英文,the,to,&lsquo,href&rsquo,linkobj.getAttr等相关知识,佚名 希望在学习及工作中可以帮助到您

英文:A链接标记ie下会自动补全href.
Whilst working on the Ajax Link Tracker and MapSurface I have come across an inconsistency in how the href attribute is retrieved using DOM Scripting.
The href attribute is different to other element attributes in that the value set can be relative to the context of the page URL. If you set a link with a relative href attribute
<a href="../development/test1.html">test page</a>
The browser will look at the pages current URL and derive an absolute URL for the link.
http://www.glenn.jones.net/development/test1.html
This is the root of the problem, some browsers return the text of the attribute and others return the derived absolute URL. The results also differ by the method you use to retrieve the href attribute. There are three common ways to access an attribute:
linkobj.href; linkobj[‘href’]; linkobj.getAttribute(‘href’);
The linkobj.href and linkobj[‘href’]; methods of accessing the attribute consistently return the derived absolute URL.
Microsoft has tried to address this by problem adding a second parameter to the getAttribute method. The second parameter can be set to 0,1 or 2. If the parameter is set to 2 the method returns the attribute text. Any other setting will return the derived absolute URL.
linkobj.getAttribute(‘href’); linkobj.getAttribute(‘href’,2); Derived
Absolute URL Attribute Text IE linkobj.href; x IE linkobj.getAttribute(‘href’); x IE linkobj.getAttribute(‘href’,2); x Gecko linkobj.href; x Gecko linkobj.getAttribute(‘href’); x Gecko linkobj.getAttribute(‘href’,2); x Opera linkobj.href; x Opera linkobj.getAttribute(‘href’); x Opera linkobj.getAttribute(‘href’,2); x Get attribute test page Test on IE6, Firefox 1.5 and Opera 8.51.
So what should be returned by the getAttribute method? The W3C DOM Level 2 Core specification which sets out the structure of the getAttribute method does not cover this issue. It is not that either approach is wrong or right. On this point the specification is open to interpretation.
As a coder I would like to be able to access both values. The DOM Core specification should be updated to address the problem.
After a really good exchange with Jim in the comments below, I stand corrected. The specification does say the getAttribute should return the attribute value, not the absolute URL. The Microsoft approach is wrong.
For the time being I am using the old school object property method linkobj.href to return derived absolute URLs. It provides the most consistent results across all browsers. URLs of interest
W3C REC DOM Level 2 Core specification for getAttribute
Gecko documentation for getAttribute
Microsoft documentation for getAttribute
As usual just as I was finishing this post I found this bug report on the QuickMode site which discusses the same subject.
getAttribute HREF is always absolute.html

您可能想查找下面的文章:

  • 浅析响应式框架中,table表头自动换行的快速解决方法
  • HTML实现页面自动跳转的五种方法
  • HTML页面3秒后自动跳转的三种常见方法
  • 文字滚动后自动停止效果示例
  • 网页中回车后form自动提交跳到其他页面的解决方法
  • 在html中禁用自动完成不让其显示历史记录
  • html中设置让div中的内容超出后自动显示滚动条
  • html中div不自动换行、强制不换行的具体实现
  • 让pre标签自动换行示例代码
  • 按回车表单自动提交问题意外发现

相关文章

  • 2017-08-05HTML是网页制作者必须要学习掌握的
  • 2017-08-05使一个input文本框随其中内容而变化长度的方法
  • 2017-08-14Html中的其他标签
  • 2017-08-05HTML页面style中里面!-- --的作用是什么
  • 2017-08-05用jquery进行修复在iframe下的页面锚点失效问题
  • 2017-08-05详解HTML中table表格的frame和rules属性
  • 2017-08-05a标签中写有文字如何隐藏文字显示图片兼容360模式渲染
  • 2017-08-05iframe去边框、无边框使用大全(实践经验整理)
  • 2017-08-05html格式化json的实例代码
  • 2017-08-05浅谈HTML空链接的作用

文章分类

  • html/xhtml
  • html5
  • CSS
  • XML/XSLT
  • Dreamweaver教程
  • Frontpage教程
  • 心得技巧
  • bootstrap
  • vue
  • AngularJS
  • HBuilder教程
  • css3
  • 浏览器兼容
  • div/css
  • 网页编辑器
  • axure

最近更新的内容

    • HTML表单提交的几种方式_动力节点Java学院整理
    • 举例讲解HTML中iframe和frame的区别
    • HTML超出文本多行截取实现原理及代码
    • 网页排版应该考虑IE6的兼容性问题
    • 向div元素添加圆角边框的实现方法
    • 被忽视的META标签之特效(页面过渡效果)
    • HTML表单传值示例通过get方式传递
    • 一些编写高性能HTML应用的建议
    • 如何实现框架窗口间的关联及超链接的target属性的使用
    • iframe的src设置为about:blank之后细节探讨

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有