0
我有一個需要在iframe中打開一個html頁面的需求,該頁面又被放置在另一個html頁面(uri以file://開頭)。需要在iframe和外部html頁面之間建立跨域消息傳遞。當iframe中的頁面從本地機器加載時(iframe中的外部頁面和頁面都具有file:// uri),它工作得非常好。使用postMessage的跨域消息傳遞
現在,如果我嘗試創建應用程序,則將其託管在本地計算機中,並在iframe中將其打開,但頁面已成功加載,但外框和iframe中的頁面之間的消息傳遞失敗。
我收到以下錯誤在Chrome中: -
Uncaught SecurityError: Blocked a frame with origin "http://localhost/newapp"
from accessing a frame with origin "null". The frame requesting access has a protocol of
"http", the frame being accessed has a protocol of "file". Protocols must match.
我已經允許託管應用程序的服務器上的跨域請求。我可以嘗試什麼其他步驟使postMessage通信成爲可能?