获取 parent.location.url - iframe - 从孩子到父母 [英] get parent.location.url - iframe - from child to parent

查看:21
本文介绍了获取 parent.location.url - iframe - 从孩子到父母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个显示在 iframe 中的页面.

I got a page that is displayed within an iframe.

我需要从那个页面(子页面)获取带有 js 的 parent.location.url.

I need to get the parent.location.url with js from that page (child page).

两个站点在不同的域中.

Both sites are in different domains.

我正在尝试:

警报(parent.location.url)

alert(parent.location.url)

但我收到此错误:

http://parentdomainhttp://childdomain.

????可能吗?

推荐答案

试试这个:

var referrer = document.referrer;
alert(referrer);

这篇关于获取 parent.location.url - iframe - 从孩子到父母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆