如何在弹出窗口被阻止时通过javascript打开新窗口 [英] how to open new window through javascript when pop up is blocked

查看:89
本文介绍了如何在弹出窗口被阻止时通过javascript打开新窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当在IE和Firefox中阻止弹出窗口时,如何通过javascript打开一个新窗口。

How can I open a new window through javascript when popup is blocked in IE and Firefox.

以下是代码:

<%@ Page language="c#" AutoEventWireup="false" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 

<html>
  <head>
    <title>SessionRedirect</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name=vs_defaultClientScript content="JavaScript">
    <meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
  </head>
  <body MS_POSITIONING="GridLayout">

    <form method="post" name="frmRedirect">   
        <input type="hidden" name="email" value="<%=Session["Email"].ToString() %>" />
        <input type="hidden" name="pass" value="<%= Session["PWD"].ToString() %>" />
        <input type="hidden" name="User" value="<%= Session["User"].ToString() %>" />
    </form>

<script type="text/javascript"> 

    if(frmRedirect.User.value == "P")
    {
        window.open("", "Partner", "height=650,width=1075,left=100,top=100,status=1,scrollbars=1,location=1,toolbar=1;resizable=1");
        frmRedirect.target="Partner";       
        frmRedirect.action = "http://pli.cmsstag/partnerzone/index.aspx";
        document.frmRedirect.submit(); 
        location.replace("index.aspx");
    }
    else
    {
        window.open("", "Student", "height=650,width=1075,left=100,top=100,status=1,scrollbars=1,location=1,toolbar=1;resizable=1");
        frmRedirect.target="Student";
        frmRedirect.action = "http://pli.cmsstag/studentzone/index.aspx";
        document.frmRedirect.submit(); 
        location.replace("index.aspx");
    }   

</script>

<%
    Session.Remove("registration");
    Session.Remove("User");
    Session.Remove("UserId");
    Session.Remove("UserLoggedIn");
    Session.Remove("AgentCode");
    Session.Abandon();
%>

  </body>
</html>

所有上述代码都正常工作,直到浏览器阻止了弹出窗口。我试图通过window.open打开新窗口,请看上面的代码。我希望窗口在任何情况下都应该打开,如果有弹出窗口阻止程序它也应该打开。
请帮助!

all the above code is working fine, until the browser has blocked the popup. I am trying to open new window through window.open, please see the above code. I want the window should open in any case, if there is pop up blocker it should also open. Please help!

推荐答案

由window.open创建的弹出窗口可能被弹出窗口阻止程序阻止。你可以添加一个新的div层,就像弹出一样来解决这个问题。

Pop ups created by window.open can get blocked by pop up blockers. You can add a new div layer that acts like a pop up to solve this.

Javascript模态对话框

div弹出窗口的一些问题是

Some of the problems with div pop ups are

。下拉列表会影响这些弹出窗口。

. dropdown lists come in the way of these pop ups.

。在窗口调整大小的位置必须更改

. on window resize the position has to be changed

在上面的页面中有很多问题div pop up已经解决了。

In the above page many of the issues with a div pop up has been solved.

这篇关于如何在弹出窗口被阻止时通过javascript打开新窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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