0
我有一個頁面,其中包含一個從amazon aws s3存儲區加載html模板的iframe。在iframe中,我想獲取父窗口的鏈接,然後添加一些參數。javascript iframe:從https訪問http
例如:我的父窗口有鏈接http://xx.xx.x.xxx:8088。我想採取此網址,apprend「#abc/edf」並重定向到該頁面。但我不能,因爲我的iFrame擁有URL https://bucketName.s3.amazonaws.com
我得到的是
Uncaught SecurityError: Blocked a frame with origin "https://bucketName.s3.amazonaws.com" from accessing a frame with origin "http://xx.xx.x.xxx:8088". The frame requesting access has a protocol of "https", the frame being accessed has a protocol of "http". Protocols must match.
我用來重定向到另一個頁面,從一個iFrame
function navigateTo(e){
var destination = e.data.destination;
var url = window.parent.location.host;
window.parent.location.href = url+destination;
}
$("#button").click({destination: "/#abc/edf"}, navigateTo);
HTML
<div id="button"><a href="#">Redirect to another page</a></div>
在JavaScript錯誤
我無法使用絕對路徑的原因。父窗口鏈接將以某種方式改變。我認爲最好的解決方案是採取父網址,並追加我想要的參數。我如何在不發生安全錯誤的情況下做到這一點?