Avoding Cross-Domain Security Error before accessing windowattributes?

E

Erwin S. Andreasen

Hi,

I have a web application where window A opens window B (same site). B
later wants to do something depending on whether
the window A, window.opener.document.domain, has changed.

However, there doesn't seem to be a way to actually check whether A
has moved to a different domain without triggering (in IE) a security
violation and completely aborting the script. If the user has enabled
debugging, this also brings up an annoying dialog box.

I'd like to either catch this exception somehow or be able to tell
beforehand whether I can access window.opener.* attributes
successfully. According to:

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/om/xframe_scripting_security.asp

the only thing I can do is to *write* to the various attributes.

Can anyone suggest a way to work around this? I am not interested in
accessing the location/domain of the new page, just whether the window
has left my domain.
 
K

Kien

It is good that you CANNOT do this.
I think you are trying to spy and police users' movement.
If you want users to stay with your site make it attractive.

Kien
 
M

Martin Honnen

Erwin S. Andreasen wrote:

I have a web application where window A opens window B (same site). B
later wants to do something depending on whether
the window A, window.opener.document.domain, has changed.

However, there doesn't seem to be a way to actually check whether A
has moved to a different domain without triggering (in IE) a security
violation and completely aborting the script. If the user has enabled
debugging, this also brings up an annoying dialog box.

Well by now J(ava)Script supports try/catch, with IE since IE5, with
Netsape since Netscape 6, so at least for those and other new browsers
like Opera 7, Safari you can certainly use
try {
// access other window here
}
catch (e) {
// handle exception here
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top