Lisaweb Posted November 23, 2009 Share Posted November 23, 2009 Hi Everyone! I am new here. I tried to tackle this problem to no avail, so I decided to go to the experts! I want to call this script by Google in my PHP ecommerce skin: <div id="google_translate_element"></div><script> function googleTranslateElementInit() { new google.translate.TranslateElement({ pageLanguage: 'en', includedLanguages: 'da,nl,fr,de,el,iw,it,ko,ru,es,sv' }, 'google_translate_element'); } </script><script src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script> only on pages that are *not* https. So I am trying to embed the Google code into this directive: <script type="text/javascript"> if (document.location.protocol != "https:") document.write('...[GOOGLE CODE HERE]...'); </script> This is what I have so far, it looks clean on my editor, but it still isn't working: <script type="text/javascript"> if ( document.location.protocol != "https:" ) document.write('<div id="google_translate_element"></div> <script> function googleTranslateElementInit() { new google.translate.TranslateElement({ pageLanguage: 'en', includedLanguages: 'da,nl,fr,de,el,iw,it,ko,ru,es,sv' }, 'google_translate_element'); } </script><script src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script> </div> '); </script> Any help you experts can provide this newbie would be greatly appreciated! (Could also try doing this in php, but I don't know how.) Quote Link to comment Share on other sites More sharing options...
Lisaweb Posted November 24, 2009 Author Share Posted November 24, 2009 Well ends up someone on another forum answered my question. Here's the code that fixes the problem for anyone who searches for this problem in the future: <?php if(!($_SERVER['HTTPS'])) { ?> <div id="google_translate_element"></div><script> function googleTranslateElementInit() { new google.translate.TranslateElement({ pageLanguage: 'en', includedLanguages: 'da,nl,fr,de,el,iw,it,ko,ru,es,sv' }, 'google_translate_element'); } </script><script src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script> <?php } // End of if statement. ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.