当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - include script to page

问题描述:

I am trying to include script to any client's page. I create firefox extension which find tag and appendChild there with my script. And that works fine.

And it works when client use http pages (It load properly and execute)

But that doesn't work when client use https pages (it load properly but not execute).

I have the same code for http and https. In my code I haven't special http and https conditions. Anyone know what can be wrong ?

I think code is ok, but ok, examples:

Injecting script (in extension):

 var myScript = top.window.content.document.createElement('script');

myScript.type = 'text/javascript';

myScript.setAttribute('src','http://path/to/my/script.js');

myScript.setAttribute('onload', 'firefoxInit()');

top.window.content.document.getElementsByTagName('body')[0].appendChild(myScript);

Code to execute:

var manipulate = (function(){

alert('duper execute');

}());

网友答案:

https will not let you run insecure content like scripts from a non-secured url, so your http-hosted script.js won't be allowed to run. Mixed content is blocked by default in the current versions of Firefox and Chrome (not checked IE)

分享给朋友:
您可能感兴趣的文章:
随机阅读: