- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
RESOLVED: No matter what I try, loading external JS file does not work. Help?
RESOLVED: No matter what I try, loading external JS file does not work. Help?
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report
Please ignore. The file was HTTP and should have been HTTPS. Mixed content was being blocked.
Hi guys. I've tried everything I can think of to get an external script to load to no avail.
I've tried https://developers.optimizely.com/classic/javascript/code-samples/index.html#helpers-external-js to a T and the script is not loaded on the page.
I put the below in my experiment JS and nothing happens on the page. I've tried simple methods like appending and again, nothing happens.
var loadScript = function(location, callback){
var fileRef = document.createElement('script');
fileRef.setAttribute('type','text/javascript');
if (callback) {
if (fileRef.readyState) { // IE
fileRef.onreadystatechange = function() {
if (fileRef.readyState == 'loaded' || fileRef.readyState == 'complete') {
fileRef.onreadystatechange = null;
callback();
}
};
} else { // Non-IE
fileRef.onload = function(){
callback();
};
}
}
fileRef.setAttribute('src', location);
document.head.appendChild(fileRef);
};
loadScript('http://www.site.info/_files/cc_validate.js', function() {
});
Re: RESOLVED: No matter what I try, loading external JS file does not work. Help?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report
Hello,
Glad to hear the issue was resolved. Thanks for posting to Optiverse!
Best,
Rocky