Cha*_*lie 3 html javascript iframe jquery
我正努力在我的iframe中获取parenet URL(即在浏览器中显示的url).我的父网站是gslb13.aaa.com.内部有一个iframe,我在其中加载我的网站test.elasticbeanstalk.com(注意两者都在不同的域中)点击smile链接gslb13.aaa.com.它将加载test.elasticbeanstalk.comiframe内部.
要获得我尝试过的父网址
var url = (window.location != window.parent.location) ? document.referrer: document.location;
alert(url);
Run Code Online (Sandbox Code Playgroud)
我在test.elasticbeanstalk.com的索引页面中获取父URL(在加载时).然后:
1)我点击test.elasticbeanstalk.com中的"添加"按钮转到下一个视图
2)在add.jspx中重复相同的代码以获得相同的父URL
但不幸的是我得到了test.elasticbeanstalk.com的网址(非父网址:gslb13.aaa.com)
可以任何人建议我处理这个问题吗?