Question

I hope someone can help me.

I have a website that uses javascript to open a popup that exists at another domain.

On the popup, I want a "book now" link/button that will change the page of the parent website to it's booking.htm page, and then the popup closes.

There is no possibility of hosting the popup on the same domain as the main website.

I have tried two code types to change the page location...

1)

window.opener.location.href="booking.htm"

2)

window.opener.window.location.href="booking.htm"

In Firefox 6 and Chrome 12 - Both 1 and 2 work perfectly.

In Internet Explorer 8 - Method 1 causes the parent window to throw a yellow popup bar, giving the user option to temporarily allow popups. Method 2 gives an "Error on Page" on the popup window and gives the explanation "Permission Denied".

In Opera 11.51 - Both methods throw an error in the Error Console of "Uncaught exception: ReferenceError: Security error: attempted to write protected variable"

I'm pretty sure that the issues are to do with the main website and the popup being on different domains, but again hosting them on the same domain is not an option.

So I'm asking..

  • is there a way for code on a popup to change the page location of its parent when they are on different domains, that works cross browser?
  • why does Internet Explorer throw a yellow popup bar in method 1, when I'm not using using window.open, I'm using location.href? i.e. I'm asking the parent to change location not open a new popup.
  • have I missed out using some sort of "target=" code?
  • do I need to use some kind of "return false;" or something?

[I had an example here, but have now removed it as I set up an extra web hosting account to show the cross domain issue in action. But I don't need the extra web host now, so am cancelling it to save money. Sorry for the inconvenience]

Thanks for reading this far even if you can't help out.

Dave

Was it helpful?

Solution

You cant do this cross domain. In child popup page redirect to the parent's domain and that page than can simply refresh/redirect the opener or you can access it as it will be same domain.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top