如何关闭父窗口中的弹出窗口? [英] How to close a popup window in a parent window?

查看:73
本文介绍了如何关闭父窗口中的弹出窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要关闭一个由父窗口加载的弹出窗口.

I need to close a popup window which has been loaded by a parent window.

此弹出窗口是我的Web应用程序中的一个 Documentviewer 窗口.

This popup window is a Documentviewer window in my webapp.

我需要通过单击母版页中的注销按钮来关闭此查看器.

I need to close this viewer by clicking a logout button which is in master page.

我的代码:

public string MySession //server side code

{
    get 
    {
        if (Session["RegID"] != null)
        {
            return Session["RegID"].ToString();
        }
        else
        {
            return "";
        }
    }

}


//client side code
   $(window).load(function() {

      Start();
   });


    function Start()
    {
      timedCount();
      var t=setTimeout("Start()",10000);
    }


   function timedCount()
   { 
     /*var out="<%=Session["RegID"]%>";*/


      var out='<%=MySession%>'; 
      if(out!="")
      {
        alert(out);       
      }else
      {
        window.close();
      }

   }

服务器代码仅在第一次执行.

Server code is executed at very first time only.

我的目标是在用户注销时关闭弹出窗口.

My target is to close the popup if it is opened when user logs out.

推荐答案

您的父页面上可能有类似的内容:

You probably have something like this on your parent page:

window.open(...);

如果将其更改为:

var popup = window.open(...);

然后您随时可以通过编码将其关闭:

then at any time you can close it by coding:

popup.close();

http://jsfiddle.net/pimvdb/bjkNx/1/

这篇关于如何关闭父窗口中的弹出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆