弹出窗口的替代(相同功能)

时间:2012-06-16 19:47:13

标签: c# web popupwindow

我正在开发一个网站(C#,。Net 3.5 Framework)并寻找替代Popup window以避免浏览器的弹出窗口阻止程序设置,或者换句话说想要删除网站弹出窗口拦截器的依赖关系。许多用户因为不喜欢而禁用它们。

我正在使用菜单的母版页和网站的通用界面。

但所有要求都是一样的。

  1. 重叠窗口
  2. Common Interface/component可用于显示其他HTML / ASPX页面的内容
  3. 值可以是passed and returned到开启者窗口。
  4. 这种情况的最佳选择是什么?

    感谢。

2 个答案:

答案 0 :(得分:1)

你最好的选择是javascript,也许是jquery的模态插件,但是......问题是,它不是100%可靠的。许多人禁用javascript或者没有带有js的浏览器(一些较旧的手机等)。

答案 1 :(得分:0)

我找到了一种方法,作为弹出窗口的替代。

样式表(与弹出相关的CSS)
目的:弹出窗口的CSS

.PopupOuterDiv
{
height:100%;
width:100%;
top:0px;
left:0px;
background-color:#000000;
filter:alpha(opacity=50);
-moz-opacity:.50;
opacity:.50;
z-index:50;
}

.PopupInnerDiv
{
position:fixed;
background-color:#ffffff;
z-index:50;
left:25%;
right:25%;
top:25%;
border-right: #0066ff 5px solid;
border-top: #0066ff 5px solid;
border-left: #0066ff 5px solid;
border-bottom: #0066ff 5px solid;
font-family: Arial;
}

.PopoupTitle
{
background-color: #0066ff;
height:25px;
color: white;
}

.PopoupButton
{
color: #ffffff;
width:20px;
border:white 1px solid;
background-color: #663300;
}

母版页
目的:包含弹出的公共代码

1.为外褪色效果创建1 Div 2.创建Div作为容器或弹出窗口
3.在容器DIV中创建iframe并分配URL。

 <div class="PopupOuterDiv" runat="server" id="PopupOuterDiv" style="display:none;"></div>
    <div class="PopupInnerDiv" runat="server" id="PopupInnerDiv" style="display:none;">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr class="PopoupTitle">
            <td id="PopoupTitle"></td>
            <td align="right">
                <input class="PopoupButton" type="Button" value="X" onclick="closePopup();" />
            </td>
        </tr>
        <tr style="height:8px;" ><td></td></tr>        
        <tr>
            <td colspan="2">&nbsp;
            <iframe id="PopupIframe" src="" runat="server" height="300px" width="480px"></iframe> 
            </td>
        </tr>
    </table>
    </div>

JavaScript 打开和关闭弹出窗口

   function closePopup()
  {
    document.getElementById('<%=PopupOuterDiv.ClientID%>').style.display = 'none';
    document.getElementById('<%=PopupInnerDiv.ClientID%>').style.display = 'none';
  }

  function openPopup(PopupTitle, PopupURL)
  {
    document.getElementById('<%=PopupOuterDiv.ClientID%>').style.display = '';
    document.getElementById('<%=PopupInnerDiv.ClientID%>').style.display = '';
    document.getElementById('PopoupTitle').innerText = PopupTitle;    
    document.getElementById('<%=PopupIframe.ClientID%>').src = PopupURL;    
  }

内容页面

从任何内容页面调用弹出窗口。

openPopup('My Custom Popup', '../aspx/User.aspx');