function RedirNonHttps() { if (location.href.indexOf("https://") == -1) { location.href = location.href.replace("http://", "https://"); } } Then, simply call the RedirNonHttps function on page load : onload="RedirNonHttps();"
function RedirNonHttps() { if (location.href.indexOf("https://") == -1) { location.href = location.href.replace("http://", "https://"); } } Then, simply call the RedirNonHttps function on page load : onload="RedirNonHttps();"