SecurityError:阻止具有原點的幀訪問跨源幀我正在<iframe>我的HTML頁面中加載一個并嘗試使用Javascript訪問其中的元素,但是當我嘗試執行我的代碼時,我收到以下錯誤:SecurityError: Blocked a frame with origin "http://www.<domain>.com" from accessing a cross-origin frame.你能幫我找一個解決方案,以便我可以訪問框架中的元素嗎?我正在使用此代碼進行測試,但徒勞無功:$(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:阻止具有原點的幀訪問跨源幀
九州編程
2019-05-27 16:40:11