如何使用javascript重定向父页面

如何使用javascript重定向父页面,javascript,Javascript,我想问你们如何将父页面从一个小页面重定向到一个特定的url?我尝试了几个选项,如parent或opener,但没有任何效果。请帮我理解出了什么问题 以下是我使用的代码: <html> <head> <script> function openWin(){ myWindow=window.open('','','width=200,height=100'); myWindow.document.write("<p>Th

我想问你们如何将父页面从一个小页面重定向到一个特定的url?我尝试了几个选项,如
parent
opener
,但没有任何效果。请帮我理解出了什么问题

以下是我使用的代码:

<html>
<head>
<script>
  function openWin(){
       myWindow=window.open('','','width=200,height=100');
       myWindow.document.write("<p>This is 'myWindow'</p> <button onclick=\"window.opener.location.href = ='http://www.google.com'; window.close();\">refresh</button>");
       myWindow.focus();
  }
</script>
</head>
<body>

   <input type="button" value="Open window" onclick="openWin()" />

 </body>
 </html>

函数openWin(){
myWindow=window.open('','',宽度=200,高度=100');
myWindow.document.write(“这是‘myWindow’

刷新”); myWindow.focus(); }
您的代码中有一个错误。应该是

myWindow.document.write("<p>This is 'myWindow'</p> <button onclick=\"window.opener.location.href = 'http://www.google.com'; window.close();\">refresh</button>");
myWindow.document.write(这是“myWindow”

刷新”);

i、 例如,在
'之前删除额外的
=
http://www.google.com“

您应该能够使用浏览器的内置调试工具自行确定问题。如果你有权访问这样的浏览器,打开开发者工具控制台的弹出窗口,当你点击按钮时,看看上面写着什么。如果你使用chrome或firefox,你可以按F12,在控制台中看到错误。啊,是的。非常感谢。原谅我的粗心