I'm trying to covert links in src tags to https://
. More accurately Youtube iframes. For example:
<iframe width='650' height='365' src="http://www.youtube.com/embed/y9kBixgYKzw" frameborder="0" allowfullscreen></iframe>
I tried the below code with no luck:
function RedirNonHttps() {
if (location.src.indexOf("https://") == -1) {
location.src = location.src.replace("http://", "https://");
}
}
<body onload="RedirNonHttps();">
Can someone point me out the correct way to do this?