標籤:blog http 檔案 資料 os art
http://blog.csdn.net/andyxm/article/details/5219919
我們引用本地flash,實現flash與js雙向互動。
function thisMovie(movieName) {
if (window.document[movieName]){
return window.document[movieName];
}else if (navigator.appName.indexOf("Microsoft")==-1){
if (document.embeds && document.embeds[movieName])
return document.embeds[movieName];
}else{
return document.getElementById(movieName);
}
}
在提交資料時,flash無法跨域http訪問。於是將flash資源放置該伺服器下,接下來問題是flash與js不在一個域下,又有了互動跨域問題。解決辦法是將原來
<embed>
<param name="allowScriptAccess" value="sameDomain" />
<embed src="" allowScriptAccess="sameDomain"/>
改為了可跨域訪問
<embed>
<param name="allowScriptAccess" value="always" />
<embed src="" allowScriptAccess="always"/>
那如果我們用瀏覽器訪問http://example1.com/index.php這個頁面,在這個頁面中引用了http://example2.com /flash.swf這個flash檔案,然後在flash代碼中向http://example3.com/webservice.php發送HTTP 要求。
就需要在example3中添加crossdomain.xml,允許example2的訪問。
<cross-domain-policy>
<allow-access-from domain="example2.com" />
</cross-domain-policy>