We are all familiar with the problem of mixed scheme (http / https) content on a page.
I'm working on a site on which this is unavoidable. I do not want to prevent this. I know there are a ton of questions / answers on that.
What I need is simply to detect this (via JavaScript?) so I can tweak the page behavior (show a notice of degraded behavior or something). Any help?
Using jQuery you can find out if any insecure items are present on a page using the following piece of code:
Images, JS, CSS are all the insecure content that I could think of. Perhaps there are more, but you could easily add'em up as you find.
It's hacky, but I managed to fix this in all browsers with just JavaScript. Let me see if I can sketch it out.
We have this basic encrypted page:
When
URL_WHICH_IS_MAYBE_INSECURE
is https, all is good. But whenURL_WHICH_IS_MAYBE_INSECURE
is http, IE will not load the content unless the user OK's insecure/mixed content. I want to tell the user the page is kinda busted until they click allow. For reasons I can't go into, I know all the sites are trustworthy. Just some of them do not support SSL and the parent site needs to.AFAIK, I cannot detect this dialog / semi-loaded state with JS. But what I can do is run JS over an insecure connection IF they allow it (which also makes the iframe go). So only when
URL_WHICH_IS_MAYBE_INSECURE
is http & the site is https (mixed) I add two bits of code + HTML.and the script is
So it works like this.
Hope this helps someone.
Cheers, Michael