When someone opens my webpage I would like a popup to open, and then I would like the main page (not the popup) to redirect to another website.
I have tried:
ClientScript.RegisterStartupScript(
this.GetType(),
"popup",
"<script language=javascript>window.open('http://someURL.com','PrintMe','height=650px,width=1024px,scrollbars=1');</script>");
followed by
Response.Redirect("http://www.google.com");
While the redirection is working properly, the popup is not being displayed.
You can use below code:
Common function for open PopUp window:
put this function at your common master page
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
}
}
and Call this function like below:
PopupCenter('http://www.google.com', 'Widow Title', '1000', '1000');
in your case you have top apply like this:
Page.ClientScript.RegisterStartupScript(this.GetType(),"CallMyFunction","PopupCenter('http://www.google.com', 'Widow Title', '1000', '1000');",true);
Hope it will help you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.