Opened 8 years ago

Closed 3 years ago

#13677 closed defect (fixed)

dojo.hash uses wrong base URL when used from outside an iframe in Google Chrome

Reported by: incloud-sam Owned by: Rob Retchless
Priority: high Milestone: 1.11
Component: Core Version: 1.6.1
Keywords: Cc:
Blocked By: Blocking:

Description

Using Google Chrome 13, I have a page with an iframe. When calling dojo.hash() from inside the iframe, the hash of the iframe is updated, which is fine.

But I want to change the "outer" hash of the outer website. When using

top.dojo.hash('some=thing', true)

the hash of the outer website is updated, but the URL also changes to the URL of the iframe.

I assume that the dojo hash function does not respect the current window, but just uses the global window object to get the base url.

Attachments (2)

testcase.zip (1.8 KB) - added by Jared Jurkiewicz 7 years ago.
Testcase that illustrates the problem
13677.patch (900 bytes) - added by Jared Jurkiewicz 7 years ago.
Potential patch for the issue.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 8 years ago by incloud-sam

As a side note, it works in firefox.

comment:2 Changed 8 years ago by Adam Peller

Owner: set to Rob Retchless

Changed 7 years ago by Jared Jurkiewicz

Attachment: testcase.zip added

Testcase that illustrates the problem

comment:3 Changed 7 years ago by Jared Jurkiewicz

Folks. We also hit this at my place of employment. I've attached a testcase that demonstrates the issue exactly. It's a very odd browser behavior. If you print out 'location/href' right in dojo.hash, you get the right URL, even if you call it from another iframe. BUT, when dojo.hash does:

location.href = "#" + hash;

It suddenly decides to use the url from the IFRAME! This seems to occur IF the iframe is in the middle of a load at the time the dojo.hash() call is made. If you put setTimeouts around the hash and iframe call, it works (see testcase).

So this appears to be some strange browser behavior that when you print location.href, you get the right thing, but if you invoke a change on it (and the change is just a hash), then it grabs the URL off the loading iframe.

Very strange behavior, indeed.

You can actually see this in action with the testcase. In firebug, turn on persist, then run it and click the link. You'll see it print the right base url, yet when location.href = "#" + hash is executed, it decides to use the iframe URL.

The good news is I have a fix for it that seems to work. As long as you set the ENTIRE url, not just trying to assign href = "#" + hash; it doesn't screw up. See the 13677 patch I attached.

Changed 7 years ago by Jared Jurkiewicz

Attachment: 13677.patch added

Potential patch for the issue.

comment:4 Changed 7 years ago by Rob Retchless

Is this the same as: http://bugs.dojotoolkit.org/ticket/11100

If so, there's a patch ready to go over on that one, and this can be resolved as a dupe.

comment:5 Changed 3 years ago by dylan

Component: GeneralCore

comment:6 Changed 3 years ago by dylan

Milestone: tbd1.11
Resolution: fixed
Status: newclosed

Per the earlier comment, looks like this was fixed in https://github.com/dojo/dojo/commit/58ed8621b7f1c5bb923f0f7172448738c31df904

Note: See TracTickets for help on using tickets.