0

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 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

Indeed, all the sites i tried used https, how dumb of me overlooking such a thing. The bookmarklet works perfectly on http sites. Cheers for the reply!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.