Opened 10 years ago
Closed 5 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)
Change History (8)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
Owner: | set to Rob Retchless |
---|
comment:3 Changed 9 years ago by
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.
comment:4 Changed 9 years ago by
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 5 years ago by
Component: | General → Core |
---|
comment:6 Changed 5 years ago by
Milestone: | tbd → 1.11 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Per the earlier comment, looks like this was fixed in https://github.com/dojo/dojo/commit/58ed8621b7f1c5bb923f0f7172448738c31df904
As a side note, it works in firefox.