0

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

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

但是所有的要求都是一样的。

  1. 重叠窗口
  2. Common Interface/component可用于显示其他 HTML/ASPX 页面的内容
  3. 值可以是passed and returnedOpener Window。

对于这种情况,哪个是最佳选择?

谢谢。

4

2 回答 2

1

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

于 2012-06-16T19:51:21.507 回答
0

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

样式表(Popup 相关的 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');
于 2012-07-10T17:51:13.530 回答