I'm trying to integrate Whatsapp button on my magento website.
I added the following code to my head.phtml
<script type="text/javascript">if(typeof wabtn4fg==="undefined"){wabtn4fg=1;h=document.head||document.getElementsByTagName("head")[0],s=document.createElement("script");s.type="text/javascript";s.src="<?php echo Mage::getBaseUrl() ?>js/whatsapp/whatsapp-button.js";h.appendChild(s);}</script>
I get the following console error when I visit secure url pages because .js url is always http://
Mixed Content: The page at
'https://www.mywebsite……' was loaded over
HTTPS, but requested an insecure script
'http://www.mywebsite…./whatsapp-button.js'. This
request has been blocked; the content must be served over HTTPS.
Is there a way to get secure base url on secure pages and unsecure base url on unsecure pages?
Best Answer
You could try the solution posted here: https://stackoverflow.com/questions/1411531/magento-ssl-links
That way it will return a secure or insecure link depending on whether or not the current page is secure.