我需要從另一個(gè)域中的Iframe訪問父域URL。例如,“ example.com”是我的網(wǎng)站,該網(wǎng)站具有來自另一個(gè)父域(例如“ google.com”)的iframe。在這里,我需要從example.com訪問父域URL。也就是說,我需要在“ example.com”域中獲取網(wǎng)址“ google.com”。此外,父域不能被硬編碼。我嘗試使用以下代碼:window.parent.location.href()但這會(huì)導(dǎo)致訪問被拒絕錯(cuò)誤。我該如何正確實(shí)施以實(shí)現(xiàn)此目標(biāo)?
如何使用Javascript從iframe實(shí)施跨域URL訪問?
收到一只叮咚
2019-12-02 13:07:17