getAttribute("HREF") is always absolute

Atom RSS

This site heavily relies on bug reports created by its readers. Anyone can report a bug and be published.

Main navigation:




Search reports by browser:

In some browsers getAttribute("HREF") on an A element returns a complete URL, even if the HREF attribute in the source specified a relative path. In others it returns the exact text of the attribute in the source, which may be relative.

All browsers put the complete, resolved, URL for an A element in its .href property. In Explorer (Win and Mac) and Opera 8 the same value is returned by getAttribute("HREF"), while Mozilla (FF1.0), Safari and Konqueror (3.2.2) return the source value. I consider the latter behaviour to be correct.

The test case contains two links, the first absolute and the second relative, and reports the values of .href and getAttribute("HREF") for each. It is the last reported value that differs.

Test page Workaround is not included
Reported by: Phil Endecott.

Explorer 5-6 Windows, Explorer 7 beta 2, Explorer Mac, Opera | Reported on 25 February 2005.

Comments

(Add your own)

Posted by Luis IƱiguez on 26 March 2005

1

You can use the flag "2" in the getAttribute() method. Example: getAttribute("href",2)

Post a comment

Commenting guidelines:

  1. When quoting specs, articles or your own research, please include a URL of the document.
  2. Test your stuff. When reporting browser behaviour, make sure that your report is correct.

Yes