4
我有一個網站example.com
,我服務的所有外部資源從cdn.example.com
。所以在我的HTML頁面在example.com
我有類似:如何使用從子域提供的腳本創建Web Worker?
<script type="text/javascript" src="http://cdn.example.com/script.js"></script>
在我的劇本,我想創建一個Web工作,所以我做的:
worker = new Worker("http://cdn.example.com/script.js");
但這未能在Firefox 16 Failed to load script: http://cdn.example.com/script.js (nsresult = 0x805303f4)
錯誤。它適用於Safari 6和Chrome 22.
看來問題是因爲origins differ。該腳本的有效起源是example.com
和cdn.example.com
不符。這似乎是一個錯誤,因爲沒有CORS沒有設置document.domain
幫助(或者至少我不能讓它通過玩這個工作)。有什麼辦法可以使它工作嗎?
[CSP](https://developer.mozilla.org/en-US/docs/Security/CSP/Introducing_Content_Security_Policy)可以幫助嗎? – pd40
好主意。試過。可悲地買它不起作用(沒有改變)。所以這個問題只與Firefox有關。 – Mitar
我打開了一個bug:https://bugzilla.mozilla.org/show_bug.cgi?id = 806752 – Mitar