我生成I幀動態地對很多不同的隨機網站,我傾向於在我的JavaScript控制檯收到此錯誤(不一定與此網址):麻煩藉助iframe
Unsafe JavaScript attempt to access frame with URL http://localhost:3000/results/ from frame with URL http://www.apple.com/iphone/. Domains, protocols and ports must match.
爲什麼我收到這個錯誤?有沒有辦法擺脫它?
所以只有兩次我在JavaScript中的I幀交互的是,當我在iframe動態加載:
$("#results_div").html('<iframe src='+url+' frameborder="0" class="iframe"><p>Browser does not support iframes.</p></iframe>');
,當我拉src
屬性的iframe:
var previewed = $("iframe").attr("src");
哪一個是導致錯誤?
這是一個安全問題;你能詳細說明一下你的iframe代碼中的Javascript/script-tags嗎? – ghayes