Forum Moderators: open

Message Too Old, No Replies

Check for https with javascript

How?

         

Easy_Coder

9:18 pm on Oct 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How do you determine if a page is secured (ssl) with javascript?

Easy_Coder

9:40 pm on Oct 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is there a better way to determine from an iframe if the parent window is secure? What I'm wanting to do is make sure that if the parent is https that the iframe loads under https too.

var loc = new String(window.parent.document.location);
if (loc.indexOf("https://")!= -1)
prefix = "https://";
else
prefix = "http://";

Bernard Marx

9:49 pm on Oct 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<edit>
prefix = parent.location.protocol + '//';

Neater (but any safer?)