admin管理员组文章数量:1023585
var win = window.open('');
console.log(window.location.pathname); // /login
How to get pathname after /login page redirect me to other page?
Thanks in advance.
var win = window.open('http://example./login');
console.log(window.location.pathname); // /login
How to get pathname after /login page redirect me to other page?
Thanks in advance.
Share Improve this question asked Jul 11, 2014 at 9:11 owlowl 4,5094 gold badges26 silver badges28 bronze badges2 Answers
Reset to default 2You can use win
not window
to retrieve it.
console.log(win.location.pathname);
Please note that you can retrieve the path only after the redirection is pleted. So I guess you can get the path data by using timer or some other events ( e.g. click ) like below:
<script>
var win = window.open('http://example./login');
function showChildURL(){
alert(win.location.href);
}
</script>
<a href="javascript:showChildURL();">showChildURL</a>
index.html
<html>
<body>
<script language="javaScript">
var win = window.open('1.html');
function showChildURL(){
alert(win.location.pathname);
}
</script>
<a href="javascript:showChildURL();">showChildURL</a>
</body>
</html>
1.html
<html>
<head>
<meta http-equiv="refresh" content="0;URL='2.html'" />
</head>
<body>
<p>This page will be redirected to 2.html</p>
</body>
</html>
2.html
<html>
<body>
This is 2.html
</body>
</html>
Hope this helps.
What you want to achive is munication between browser tabs/windows. You'll have to use cookie or localStorage to notify your main window about redirected url. Take a look at LocalConnection.
var win = window.open('');
console.log(window.location.pathname); // /login
How to get pathname after /login page redirect me to other page?
Thanks in advance.
var win = window.open('http://example./login');
console.log(window.location.pathname); // /login
How to get pathname after /login page redirect me to other page?
Thanks in advance.
Share Improve this question asked Jul 11, 2014 at 9:11 owlowl 4,5094 gold badges26 silver badges28 bronze badges2 Answers
Reset to default 2You can use win
not window
to retrieve it.
console.log(win.location.pathname);
Please note that you can retrieve the path only after the redirection is pleted. So I guess you can get the path data by using timer or some other events ( e.g. click ) like below:
<script>
var win = window.open('http://example./login');
function showChildURL(){
alert(win.location.href);
}
</script>
<a href="javascript:showChildURL();">showChildURL</a>
index.html
<html>
<body>
<script language="javaScript">
var win = window.open('1.html');
function showChildURL(){
alert(win.location.pathname);
}
</script>
<a href="javascript:showChildURL();">showChildURL</a>
</body>
</html>
1.html
<html>
<head>
<meta http-equiv="refresh" content="0;URL='2.html'" />
</head>
<body>
<p>This page will be redirected to 2.html</p>
</body>
</html>
2.html
<html>
<body>
This is 2.html
</body>
</html>
Hope this helps.
What you want to achive is munication between browser tabs/windows. You'll have to use cookie or localStorage to notify your main window about redirected url. Take a look at LocalConnection.
本文标签: javascriptHow to get window URL after redirectStack Overflow
版权声明:本文标题:javascript - How to get window URL after redirect? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745571185a2156745.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论