views:

82

answers:

1

I'm adding a facebook comment widget to a website. I'm placing this widget in a file that is included on everypage. The navigation is relatively linked so it switches back and forth from http and https. But for some reason the comment widget only shows up if both the src linked file and webpage is secure or both the src linked file and webpage is NOT secure. The widget does not display of the src file is secure and the webpage is not secure. So... I've tried this but doesn't work.

if (window.location.protocol == 'https:')
script.setAttribute('src', 'https://ssl.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php');
}
else
{
script.setAttribute('src', 'http://static.ak.connect.facebook.com/connect.php/en_US')
}

A: 

You can't change existing script tags, only make new ones.

var script = document.createElement('script');
script.type = 'text/javascript';
script.src = window.location.protocol == 'https:' ? 'https://ssl.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php' : 'http://static.ak.connect.facebook.com/connect.php/en_US';
document.body.appendChild(script);
Casey Hope