在小书签中从其他域加载 javascript 文件?

Load javascript file from other domain in bookmarklet?

我对小书签还很陌生。我正在尝试使用以下 bookmarklet/javascript 代码从我自己的 server/domain 加载 javascript 文件:

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

当我在访问 test.com 域上的页面时按下 firefox 工具栏上的小书签时,这段代码运行良好(js.js 已加载并执行)。

但是当我转到 google.com 或任何其他站点并按下小书签按钮时 http://www.test.com/js.js 甚至没有加载(查看服务器日志)

我知道跨域限制,但它们不适用于 ajax 请求和相关内容吗?

这与 CORS 无关

您正在安全页面 (https) 中加载不安全内容 (http)。安全页面上的混合内容不起作用。您还需要使用 https 提供您的脚本