![](/img/trans.png)
[英]open a popup window in asp.net without showing url of the page
[英]Open any url in popup and redirect current page in ASP.net without any button click on page load
当有人打开我的网页时,我希望打开一个弹出窗口,然后我希望主页(而不是弹出窗口)重定向到另一个网站。
我试过了:
ClientScript.RegisterStartupScript(
this.GetType(),
"popup",
"<script language=javascript>window.open('http://someURL.com','PrintMe','height=650px,width=1024px,scrollbars=1');</script>");
其次是
Response.Redirect("http://www.google.com");
当重定向正常工作时,不会显示弹出窗口。
您可以使用以下代码:
打开PopUp窗口的常用函数:
将此功能放在您的通用母版页上
function PopupCenter(url, title, w, h) {
var child;
var timer;
var guid;
var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;
width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
var left = ((width / 2) - (w / 2)) + dualScreenLeft;
var top = ((height / 2) - (h / 2)) + dualScreenTop;
child = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
if (child.focus) {
child.focus();
parent.location.assign("http://blabla.com/");// Change parent Page location
}
}
并调用此函数,如下所示:
PopupCenter('http://www.google.com', 'Widow Title', '1000', '1000');
在你的情况下,你有这样的顶级申请:
Page.ClientScript.RegisterStartupScript(this.GetType(),"CallMyFunction","PopupCenter('http://www.google.com', 'Widow Title', '1000', '1000');",true);
希望它会帮助你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.