本帖最后由 bcpxqz 于 2011-6-16 17:38 编辑
a. html和b.html不同域,a.html用iframe嵌入b.html,在chrome中有时候会出现 Adobe Flash Player安全性设置窗口(图1),在console面板中可以看到,四条"Unsafe JavaScript attempt to access frame with URL"错误,但如果你看图2,就会发现,
- "Unsafe JavaScript attempt to
- access frame with URL http://a.com/adtest/39iframe/d1.html from frame
- with URL http://a.com/adtest/39iframe/d1.html. Domains, protocols and
- ports must
- match."
chrome:10.0.648.45
flash player:10,2,154,12
代码如下:
a.htm页面结构
- <embed id="test1" name="test1" width="100" height="100"
- type="application/x-shockwave-flash"
- pluginspage="http://www.macromedia.com/go/getflashplayer"
- allowscriptaccess="always" allowfullscreen="true" quality="high"
- menu="false" wmode="transparent" src="blank.swf?num=outer">
- <iframe
- width="100" scrolling="no" height="100" frameborder="0"
- allowtransparency="true" marginheight="0" marginwidth="0"
- src="http://b.com/b.html" name="iframe1"
- id="iframe1"></iframe>
import flash.external.ExternalInterface;
ExternalInterface.call("console.info",str);
Iframe b.html页面结构
- <embed id="AC86_5500" name="AC86_5500" width="100"
- height="100" type="application/x-shockwave-flash"
- pluginspage="http://www.macromedia.com/go/getflashplayer" allowfullscreen="true"
- quality="high" menu="false" wmode="transparent"
- src="blank1.swf">
本帖最后由 ticore 于 2011-6-17 18:59 编辑 http://blog.richmediaplus.com/20 ... omain-inject-issue/ 反覆測試之後,將問題簡化如下: 1. a.com 下的 HTML 網頁,包含一個 b.com 來的 iframe 網頁 2. b.com iframe 網頁內使用 javascript touch 一下 window.top.location 3. a.com 在 onload 完成後,動態建立一 Flash 物件 4. Flash 物件內透過 ExternalInterface 呼叫任何 Javascript Function 5. 得到以下錯誤訊息 SecurityError: Error #2060: 執行程序安全性違規:ExternalInterface 呼叫者http://a.com/flash.swf 無法存取 [object]。 at flash.external::ExternalInterface$/_initJS() at flash.external::ExternalInterface$/call() at flash_fla::MainTimeline/doCallJs() 已經簡化成這樣,很明顯問題是出在 javascript window.top.location 物件上 想要避免該問題,只要在主頁上一載入立即搶先 touch window.top.location 就好了 在測試過程中,還發現另一個更嚴重的問題 跨域的 iframe 能夠透過原型鍊 prototype 插入任意 function 到 location 物件上 讓 top window 頁面呼叫並傳遞任何物件 不受跨網域安全性的限制 |