以下用做笔记。
1.如何弹出一个网页式窗体,如图:
此窗体弹出后,不能操作父窗体 。
html(js)代码:
<script type="text/javascript" language="javascript">
function ShowNewPage() {
var url = '/Pupop1.aspx';
window.showModalDialog(url, window, "dialogWidth:600px;status:no;dialogHeight:400px");
return false;
}
</script>
<asp:LinkButton ID="btn1" runat="server" OnClientClick="return ShowNewPage();">弹出新窗体</asp:LinkButton>
2.弹出网页式窗体,如下图:
此窗体弹出后,可以操作父窗体 。
html(js)代码:
<script type="text/javascript" language="javascript">
//url 弹出的页面地址,title弹出页面的标题,w弹出页面宽度,h弹出页面的高度
function OpenWindow(url, title, w, h) {
var width = w;
var height = h;
var left = ($(window).width() - width) / 2;
var top = ($(window).height() - height) / 2;
window.open(RootPath() + url, title, 'height=' + height + ', width=' + width + ', top=' + top + ', left=' + left + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no, titlebar=yes, alwaysRaised=yes');
}
function attach() {
var url = "/MeetManage/Attachment.aspx?action=Add&KeyValue=" + KeyValue + "&meetname=" + escape(meetname) + "&mattname=" + escape(mattname) + "&time=" + Math.random();
OpenWindow(url, "上传附件", 450, 350);
}
</script>
<asp:LinkButton ID="btn1" runat="server" OnClientClick="attach();">弹出新窗体</asp:LinkButton>
3.关闭弹出窗体,并刷新父窗体
function btn_OK() {
window.opener.location.href = window.opener.location.href; window.close();
}
或
function btn_OK() {
window.opener.location.replace(window.opener.document.referrer);window.close();
}