Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.location - javascript - not working

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.

like image 476
Jason Avatar asked Apr 14 '26 01:04

Jason


1 Answers

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.

like image 167
jfriend00 Avatar answered Apr 15 '26 14:04

jfriend00



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!