我有一個網頁,裏面有一些javascript,它將作爲iframe嵌入到不同的網站。我需要根據所運行的網站來調整我的頁面的行爲。爲此,我想讀我的網頁top.location.href
,但引發的錯誤:獲取來自不同網域的frame/iframe的頂部窗口網址
Unsafe JavaScript attempt to access frame with URL http://website.url from frame with URL http://mypage.url . Domains, protocols and ports must match.
有一些方法去解決此問題?
不,那是不可能的任意網站。 – 2011-12-23 17:34:33
我已經提供了一個答案,下面和重複的問題http://stackoverflow.com/questions/4903351/getting-url-of-the-top-frame/19438476#19438476 – mcanfield 2013-10-17 22:34:51