Reputation: 35
I'm going to dynamically change the protocols in source of all pages on Blogger.
Eg All http:// change to https:// on below items:
<link rel="..." type="..." href="http://www.blogger.com/..." />
<script src="http://www.blogger.com/..."></script>
<iframe src="http://www.blogger.com/..."></iframe>
<a href='http://www.blogger.com/...'></a>
Upvotes: 0
Views: 2963
Reputation: 4179
You need to approach independently if you dont want to approach the first answer. Like, changing the body content (better to keep inside a div) and using the javascript function like below on page load event. For script tags which are under head tag you need to load them dynamically using other approaches like we load JSON.
<html>
<body>
<div id="content">
......
....
</div>
</body>
</html>
<script>
function replaceHTTPS()
{
var oldContent = document.getElementById ("content").innerHTML;
var newContent = oldContent.replace("http",/https/g);
document.getElementById ("content").innerHTML = newContent;
}
</script>
EDIT
First clear all the head tag using this code
document.getElementsByTagName("head")[0].innerHTML = "";
You could use following code to load the script dynamically (needs to store the script names in an static array or read them from head tag before clear)
var head= document.getElementsByTagName('head')[0];
var script= document.createElement('script');
script.type= 'text/javascript';
script.src= 'https://....filenames.js';
head.appendChild(script);
Upvotes: 1
Reputation: 22943
The best choice for you is using Protocol-Relative aka Protocol-Agnostic urls:
<link rel="..." type="..." href="//www.blogger.com/..." />
<script src="//www.blogger.com/..."></script>
<iframe src="//www.blogger.com/..."></iframe>
<a href='//www.blogger.com/...'></a>
So no need to change anything dynamically.
Upvotes: 13