[轉載]解決flash與js互動、flash跨域互動、flash跨域提交

來源:互聯網
上載者:User

標籤: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>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.