包括脚本到页面

时间:2013-09-02 12:33:33

标签: javascript https include execute

我正在尝试将脚本包含到任何客户端的页面中。我创建了firefox扩展,它使用我的脚本在那里找到tag和appendChild。这很好。 它适用于客户端使用http页面(正确加载并执行) 但是当客户端使用https页面(它正确加载但不执行)时,这不起作用。

我有相同的http和https代码。在我的代码中,我没有特殊的http和https条件。谁知道什么是错的?

我觉得代码还可以,但是好的,例子:

注入脚本(扩展名):

   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);

执行代码:

var manipulate = (function(){
   alert('duper execute');
}());

1 个答案:

答案 0 :(得分:1)

https不允许您从非安全网址运行脚本等不安全的内容,因此不允许运行您的http托管的script.js。默认情况下,当前版本的Firefox和Chrome(未检查IE)

会阻止混合内容
相关问题