简体   繁体   English

关闭弹出窗口并刷新父窗口不起作用

[英]Close Pop-up and refresh parent window not working

All of a sudden my simple javascript code to close a pop-up and refresh the parent window stopped working in Google Chrome browsers on iPad and iPhone devices.突然之间,我用来关闭弹出窗口和刷新父窗口的简单 javascript 代码在 iPad 和 iPhone 设备上的 Google Chrome 浏览器中停止工作。 It still works if we use the built in safari browser on the same devices.如果我们在相同的设备上使用内置的 safari 浏览器,它仍然有效。

Any reason why someone could see this a wouldn't work in chrome?为什么有人会看到这个 a 在 chrome 中不起作用? And by not working I mean that the pop-up closes and the parent window doesn't refresh.不工作是指弹出窗口关闭并且父窗口不刷新。

 <!---Close -Reload The Window --->
    <script type="text/javascript">
        function CloseWindow() {
            window.close();
            window.opener.location.reload(true);
        }
    </script>

            <a href="" onClick="javascript: return CloseWindow();">Signature Captured - Close Window</a>

you cant refresh page after close the window关闭窗口后无法刷新页面

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

another Type , I test it, it works.另一个 Type ,我测试它,它有效。 If you get the problem again, your browser may cause the problem.如果您再次遇到问题,则可能是您的浏览器导致了问题。

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

we located this function in the main page and call it from the popup window and it works we commented out this post - but i don't see any reference to the setTimeout we did.. so I decided to point this out and maybe it will help someone else我们在主页面上找到了这个函数,并从弹出窗口中调用它,它起作用了,我们注释掉了这篇文章 - 但我没有看到任何对我们所做的 setTimeout 的引用..所以我决定指出这一点,也许它会帮助别人

main page主页

function reloadPage() {
 if (navigator.userAgent.indexOf(' Chrome') > -1) {
    setTimeout(function () {
        location.reload(true);
    }, 0);
 } else {
    location.reload(true);
 }
}

popup page弹出页面

window.top.opener.reloadPage();

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

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