还有一个问题。我有两个页面(一个主页面和一个 window.open)。 Window.open 有一个 href 链接。如果有人按下 window.open 中的链接,如何更改主页 url 并转到该 url?
主页
//////////////////////////////
http://main.page.com
(如果在 window.open 中按下链接,则更改主页 url)
/////////////////////////////
//////////////////////
窗口.打开
href="#"链接
//////////////////////
最佳答案
在您的主页中,当然有可以打开子(其他)文件的链接:
<div class="main">
<a href="#" onclick="window.open('another_file.php', 'window', 'height=200,width=200');">Open new window</a>
</div>
然后在另一个文件上:
<a href="#" onclick="redirect_parent()">Redirect Parent to google.com</a>
<script type="text/javascript">
function redirect_parent() {
window.opener.location.href = 'http://www.google.com';
self.close();
}
</script>
当然,请将 google.com 的值更改为您想要的其他值。
关于javascript - Window.open 链接如何更改主页 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26956951/