简体   繁体   English

包含脚本到页面

[英]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. 我创建了firefox扩展,它在脚本中找到了tag和appendChild。 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). 而且它在客户端使用http页面时正常工作(正确加载并执行),但是在客户端使用https页面时(正常加载但不执行)却不起作用。

I have the same code for http and https. 我对http和https使用相同的代码。 In my code I haven't special http and https conditions. 在我的代码中,我没有特殊的http和https条件。 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. https不允许您从不安全的url运行不安全的内容(如脚本),因此将不允许您运行由http托管的script.js。 Mixed content is blocked by default in the current versions of Firefox and Chrome (not checked IE) 在当前版本的Firefox和Chrome(未选中的IE)中,默认情况下阻止混合内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM