英文: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网站设计的优势和问题
长沙网站设计
- 如何进行东阳SEO关键词优化?
- 边坝哪有关键词排名优化:提升你的网站流量与
- 安国百度优化服务:提升您的在线可见性
- 阜康新手做SEO怎么做
- 山西seo网站排名关键词优化:提升您网站曝光率
- 临沂seo网站排名关键词优化:提高你的网站可见
- 广西SEO网站推广怎样付费比较合理
- 双辽SEO网站推广:提升你的网站可见性与流量
- 辽宁企业网站优化购买方式有哪些
- 提升宝清百度SEO排名的实用技巧与策略
- 静宁百度SEO排名:提升您网站曝光率的关键策略
- 彭州百度SEO排名的提升策略和实施指南
- 广南百度关键词SEO:提升网站排名的关键策略
- 辽宁关键词优化怎么做论坛营销
- 吉林百度seo排名如何做到让用户满意
- 内黄百度优化服务:提升在线可见性的关键