Load javascript file from other domain in bookmarklet?

173 views Asked by At

I'm quite new to bookmarklets. I'm trying to load a javascript file from my own server/domain by using the following bookmarklet/javascript code:

    javascript:(function(){s=document.createElement('script');
    s.type='text/javascript';
    s.src='http://www.test.com/js.js?v='+parseInt(Math.random()*99999999);
    document.body.appendChild(s);})();

This code works nicely (js.js is loaded and executed) when i press the bookmarklet on my firefox toolbar when visiting pages on the test.com domain.

But when i go to google.com or any other sites and press the bookmarklet button the http://www.test.com/js.js isn't even loaded (looking in server log)

I know about cross domain restrictions but don't they apply to ajax request and related things?

1

There are 1 answers

1
Endless On BEST ANSWER

This has nothing to do with CORS

You are loading unsafe content (http) in a secure page (https). Mixed content on secure pages don't work. You need to serve your script with https as well