tags:

views:

26

answers:

1

I am trying to find out the protocol used by a parent window in a child window. If I use window.opener.location.protocol, it works in everything (IE8, FF3.5.5, Safari4.0.3, Chrome4) except Opera. In opera i get:

message: Security error: attempted to read protected variable 'protocol'

This used to work fine in Opera, but I guess they changed it. I am using Opera 10.10. Is there any way to test for the protocol, or even determine if the parent window is the same location and protocol as the child?

+1  A: 

You should only get the error when the protocols are different.

In other words:

var isParentSecure;
try {
    isParentSecure = window.opener.location.protocol === 'https';
catch(e) { isParentSecure = window.location.protocol !== 'https'; }

I haven't actually tested this.

SLaks