Reputation: 24815
edit: For some reason, the interval does see something, but crashes and stops looping without ever coming inside the if statement
This is my flow.
window.open()
This works fine in Chrome, but breaks on IE9.
What I've tried (both work in chrome)
In popup:
window.opener.function(data);
window.close();
In window:
var checkInterval = setInterval(function(){
if (win.variable){ // win = popup window!
clearInterval(checkInterval);
win.close();
// works!
}
}
But neither works in IE9. How do I solve this problem?
Upvotes: 0
Views: 558
Reputation: 6276
A really simple approach is to pass your variables back using anchors
So your callback url will look like this:
http://example.com/index/#var1:value1,value2/var2:value3,value4 ...
Using hashchange plugin in jQuery will make your life really easy in order to handle your problem.
Also, you can use hasher micro library using core Javascript that works in IE9
Upvotes: 0
Reputation: 1247
When the popup goes to twitter the domain is no longer the same, so in IE9 it will crash when attempting to read variables on the page.
Either do a check to see if window.opener is available (means you're on the same domain) and make sure its the same before accessing the variable (preferred) or encapsulate the if statement in a try/catch
var checkInterval = setInterval(function(){
try {
if (win.variable){ // win = popup window!
clearInterval(checkInterval);
win.close();
// works!
}
} catch (e) {}
}
Upvotes: 2