英文:A链接标记ie下会自动补全href
建站知识 2021-07-02 22:41www.168986.cn长沙网站建设
英文:A链接标记ie下会自动补全href.
Whilst working on the Ajax Link Tracker and MapSurface I have e 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://.glenn.jones./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 mon ways to aess an attribute:
linkobj.href; linkobj[‘href’]; linkobj.getAttribute(‘href’);
The
linkobj.href
and linkobj[‘href’];
methods of aessing the attribute consistently return the derived absolute URL.
Microsoft has tried to address this by
linkobj.getAttribute(‘href’); linkobj.getAttribute(‘href’,2);
Absolute URL
So what should be returned by the getAttribute method?
After a really good exchange with Jim in the ments 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 interestW3C 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
上一篇:如何通过W3C验证?
下一篇:XHTML CSS网站设计的优势和问题
长沙网站设计
- 如何自己建一个网站 自己想建个网站,怎么建
- 如何制作网站免费建站 创建网站免费注册
- html简单网页代码 html简单网页代码超链接
- dreamweaver网页制作 dreamweaver网页制作模板
- 上海网站建设 上海网站建设制作微信
- 如何制作网站和网页 如何制作一个网页
- html网页制作代码大全 端午节html网页制作代码大
- app开发公司 app开发公司前十名
- html网页制作 html网页制作文字居中
- app制作一个需要多少钱 请人制作一个app多少钱
- 成都网站制作 成都网站制作维护
- 百度建一个网站多少钱 百度做个公司网站要多少
- html+css网页制作成品 web网页制作成品css+javascrip
- html网页制作案例 html网页设计案例
- html+css网页制作成品 web网页制作成品css+javascrip
- 个人网站模板 个人网站模板HTML