H
H
homm2012-01-11 20:43:02
JavaScript
homm, 2012-01-11 20:43:02

How to know if a window is open from the current domain if field access throws an exception?

I open a new window from the page w = window.open(). After user actions on a third-party domain, a page from the current domain should open. I need to seize this moment.

I watch w.location.hostname on the timer, and if the hostname matches the current one, I do something.

The problem is that accessing w.location.hostname gives "Error: Permission denied to access property 'hostname'". Of course, you can always wrap it in a try-catch, but that's not sporty. Maybe there is a way to determine, without exception, a page from the current domain?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mayorovp, 2012-01-11
@homm

Is it possible to try to assign the definition to the page in window w?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question