SecurityError:阻止具有原點(diǎn)的幀訪問跨源幀我正在<iframe>我的HTML頁面中加載一個并嘗試使用Javascript訪問其中的元素,但是當(dāng)我嘗試執(zhí)行我的代碼時(shí),我收到以下錯誤:SecurityError: Blocked a frame with origin "http://www.<domain>.com" from accessing a cross-origin frame.你能幫我找一個解決方案,以便我可以訪問框架中的元素嗎?我正在使用此代碼進(jìn)行測試,但徒勞無功:$(document).ready(function() {
var iframeWindow = document.getElementById("my-iframe-id").contentWindow;
iframeWindow.addEventListener("load", function() {
var doc = iframe.contentDocument || iframe.contentWindow.document;
var target = doc.getElementById("my-target-id");
target.innerHTML = "Found it!";
});});
SecurityError:阻止具有原點(diǎn)的幀訪問跨源幀
九州編程
2019-05-27 16:40:11