简体   繁体   English

弹出窗口无法正常工作,无法刷新页面

[英]Pop up is not working correct, does not refresh the page

I try to open pop up in the same window, but it forwards me to another. 我尝试在同一窗口中打开弹出窗口,但是它将我转发到另一个窗口。 Also, I try to refresh window after pop up closes, but I don't find easy solution. 另外,我尝试在弹出窗口关闭后刷新窗口,但找不到简单的解决方案。 I think the best is not to put # to the URL. 我认为最好不要在网址中添加#。 That is my function: 那是我的功能:

<li value="Open window" >
    <a href="javascript: window.open('upd.php?m=<?php echo $oldpar?>','','width=520,height=400')">
        <u>EDIT</u>
    </a>
</li>

I manage open the window, however main page also goes to javascript: window.open('upd.php?m=2','','width=520,height=400') . 我设法打开窗口,但是主页也转到javascript: window.open('upd.php?m=2','','width=520,height=400') I tried to put: 我试图把:

<script type="text/javascript">
    <!--
    function refreshParent()
    {
        window.opener.location.href = window.opener.location.href;

        if (window.opener.progressWindow)
        {
            window.opener.progressWindow.close()
        }

        window.close();
    }
    //-->
</script>

It would be great to close pop up automatically after user select variables and press button. 在用户选择变量并按下按钮后,自动关闭弹出窗口将非常有用。 Immediately after the parent(main) URL would refresh.. Any help? 父(主)URL会立即刷新。 :) :)

Ps any ideas how to auto refresh pop up? PS任何想法如何自动刷新弹出? I saw all browsers have different way of doing that.. Common one? 我看到所有浏览器都有不同的方法。常见的一种吗?

  • Use "_self" as the window title (second parameter to window.open() ) to open the pop up in the same window. 使用“ _self”作为窗口标题( window.open()第二个参数window.open()在同一窗口中打开弹出窗口。

  • Use window.location.reload(); 使用window.location.reload(); to reload the current window. 重新加载当前窗口。

  • Use opener.location.reload(); 使用opener.location.reload(); to reload the window that opened the popup before calling window.close(); 在调用window.close();之前重新加载打开弹出窗口的窗口window.close();

I'm not sure, but I guess you've been looking for that. 我不确定,但我想您一直在寻找那个。

​<ul>
<li value="Open window" ><a href="javascript: window.open('upd.php?m=<?php echo $oldpar>','','width=520,height=400'); return false;"><u>EDIT</u></a></li>
</ul>

return false; at the end of the call should solve your problem. 通话结束时应该可以解决您的问题。

UPD: UPD:

http://jsfiddle.net/Mt8Vd/ http://jsfiddle.net/Mt8Vd/

To open the windows via link: 通过链接打开窗口:

<a href="javascript:open('400','360','account.php?id=<?=$id?>&type=<?=$type?>');">Open</a>

The js function to open a link: js函数打开一个链接:

<script language="JavaScript">
function open(w,h,URL)
{
  var width = w;
  var height = h;
  var left = (screen.width/2)-(w/2);
  var top = (screen.height/2)-(h/2);    
  window.open(URL,'janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}
</script>

And Finally in the end of your "popup" you should close the windows after all task get done, just telling the script to close the popup and reload the opener page. 最后,在“弹出窗口”末尾,您应该在完成所有任务后关闭窗口,只是告诉脚本关闭弹出窗口并重新加载打开器页面。

<script language="JavaScript" type="text/javascript">
function close()
{
    opener.location.reload();
    window.close();
}
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM