Javascript 如何知道跨域开放器的url

Javascript 如何知道跨域开放器的url,javascript,cross-domain,Javascript,Cross Domain,我有两个页面,有不同的域 我想知道从子页面开始的页面的url。但我无法通过opener.location完成这项工作 例如 Page1.html: <html> <head></head> <body> <script> var handle = window.open("somedomain/Page2.html"); </script> </body> </html> var handle=w

我有两个页面,有不同的域

我想知道从子页面开始的页面的url。但我无法通过opener.location完成这项工作

例如

Page1.html:

<html>
<head></head>
<body>
<script>
var handle = window.open("somedomain/Page2.html");
</script>
</body>
</html>

var handle=window.open(“somedomain/Page2.html”);
Page2.html

<html>
<head></head>
<body>
<script>
alert(opener.location) //this is not working.
</script>
</body>
</html>

警报(opener.location)//这不起作用。
我认为您可以使用散列来传递开场白url

页面1.html

var handle=window.open(“somedomain/Page2.html#opener=“+encodeURI(window.location.url));
页面2.html


var opener=decodeURI(window.location.hash.indexOf(“=”[1]);

尝试传递
窗口.开启器.位置
否则你的应用程序将不知道你的
开启器
对象

浏览器将搜索
窗口。
查找任何全局变量。