Reputation: 7682
Odd issue. I am using jQuery .postMessage()
to send messages from a secure <iframe>
to the parent. Specifically I am sending a URL and have confirmed that the parent is receiving the URL - however, when I use try to set window.location
to that URL, nothing happens.
The sent url:
http://mydomain.com/shop/507870?nav=ln-474#/shop/507870?gnrefine=1*COLOR_FAMILY*Brown%5E1*CLSR_TYP*Lace-Up%5E
The actual url:
http://mydomain.com/shop/507870?nav=ln-474#/shop/507870?gnrefine=1*COLOR_FAMILY*Brown%5E1*CLSR_TYP*Lace-Up%5E
They match. However, in Chrome, if I do a console.log(loginConfig.redirectURL);
I get:
http://mydomain.com/shop/507870?nav=ln-474#/shop/507870?gnrefine=1*COLOR_FAMILY*Brown%5E1*CLSR_TYP*Lace-Up%5E
undefined
So, I think the window.location
is getting the undefined
value.
Any thoughts on why I would be getting two values when I use the console.log
?
Update
logic:
if (message[1] != "") {
$("#loginDialog").dialog("close");
loginConfig.redirectURL = message[1];
window.location = loginConfig.redirectURL
console.log('message: '+loginConfig.redirectURL);
}
config object:
var loginConfig = {
redirectURL: ""
}
Further Update:
the window.location works on any url without a hash. So for some reason, it will not load any urls with a hash.
Upvotes: 3
Views: 410
Reputation: 707496
This part of your code is invalid:
var loginConfig = {
redirectURL = ""
}
It needs to be this:
var loginConfig = {
redirectURL: ""
}
If this leads to an error which keeps loginConfig from being properly declared with the desired property that could partly explain some unexpected behavior. You should certainly look in your browser error log and see if it reports any errors.
Upvotes: 3