How to close popup window and redirect the parent window

耗尽温柔 提交于 2019-11-30 07:02:12
J K

Tell me if this is what you are looking for... Parent Window:

<html>
<head>

    <script language="Javascript">

        function showFBWindow(){
            url = "allowfbchild.html"
            newwindow=window.open(url,'name','height=200,width=150');
            if (window.focus) {newwindow.focus()}
        }

    </script>

</head>
<body>

    <input type="button" OnClick="showFBWindow()" value="Open FB" />

</body>
</html>

Child Window(allowfbchild.html) :

<html>
<head>

    <script language="Javascript">

        function redirectToFB(){
            window.opener.location.href="http://wwww.facebook.com";
            self.close();
        }

    </script>

</head>
<body>

    Allow the user to view FB
    <br/>Are you sure?
    <input type="button" value="Ok" OnClick="redirectToFB()" />

</body>
</html>

in the parent page write the javascript as below

 <script language="Javascript">
     function popitup(url)
     {
      newwindow = window.open(url, "popwin", "width = 320, height = 210,  resizable = no");
      if (window.focus) { newwindow.focus() }
      return false;
      popwin.moveTo(0, 0);
      }
</script>

<a href=""   onclick="return popitup('myapppopup.aspx');return false;">`myapppopup</a>`

then in the popup windows add a link to facebook as below

<a href="http://wwww.facebook.com"   target="_blank"   onclick="self.close();">facebook </a>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!