The default bug view has changed. See this FAQ.

When getting a DOM element's href property, and when the href contains a space, the space is URLencoded as %20

UNCONFIRMED
Unassigned

Status

()

Core
DOM
--
minor
UNCONFIRMED
10 years ago
6 years ago

People

(Reporter: gus, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: DUPEME)

(Reporter)

Description

10 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b1) Gecko/2007110904 Firefox/3.0b1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b1) Gecko/2007110904 Firefox/3.0b1

This may sound like a trivial and even defensible bug, but it leads to incompatibilities when running some DHTML applications.  If a space is represented as a space on some browsers and as %20 in others, then string comparisons can fail in places where they wouldn't. In this code snippet:

if (these2children[k].href.indexOf(": addfield")>0)
						{
							these2children[k].href="javascript: addfield('addfield-" + OurNewNumber + "')";
							these2children[k].id="id" + "addfield-"  + OurNewNumber;
							
						}
fails to work correctly in Firefox 3.0b1 because the space is now %20.  The same code works correctly on older versions of Firefox and Internet Explorer 6 and 7.  (I haven't tried in Opera.)



Reproducible: Always

Steps to Reproduce:
1.create an href containing a space, such as <a id="id1" href="javascript: addfield(6)">
2. read the href in javascript
3. href is returned with "%20" instead of " "
Actual Results:  
20

Expected Results:  
[space]
My first search didn't find a bug that this is a direct duplicate of, but in spirit it's a duplicate of all the bugs talking about things like being surprised to get back an absolute URI when the href attribute had a relative URI - the DOM spec says .href is a URI, not the string you put in, and if you want the string you put in, you should .getAttribute("href") instead.
Component: General → DOM
Product: Firefox → Core
QA Contact: general → general

Updated

6 years ago
Whiteboard: DUPEME
You need to log in before you can comment on or make changes to this bug.