HydeNSeeka
asked on
OnBeforeUnload / window.open
I am trying to open a popup in the onbeforeunload event of an aspx page. It works fine the first time but will not do it after that. I put an alert in so I know the onbeforeunload event is firing so I think my issue is with the window.open.
Here is the code I am using
StringBuilder sbConfirmExit = new StringBuilder();
sbConfirmExit.Append("<scr ipt>");
sbConfirmExit.Append("wind ow.onbefor eunload = confirmExit;");
sbConfirmExit.Append("var postback = false; function confirmExit() { ");
sbConfirmExit.Append("if(p ostback == true) ");
sbConfirmExit.Append("even t.cancelBu bble = true; ");
sbConfirmExit.Append("else ");
sbConfirmExit.Append("Open ExitWindow ();");
sbConfirmExit.Append(" }</script>");
this.Page.RegisterStartupS cript("Con firmClose" ,sbConfirm Exit.ToStr ing());
StringBuilder sbOpenWindow = new StringBuilder();
sbOpenWindow.Append("<scri pt language=\"javascript\">") ;
sbOpenWindow.Append("var NewWindow;");
sbOpenWindow.Append("funct ion OpenExitWindow(){alert('in newwindow' );");
sbOpenWindow.Append("NewWi ndow = window.open(\"Exit.aspx\", \"win\",\" target=_bl ank,locati on=yes,sta tus=yes,to olbar=yes, menubar=ye s,scrollba rs=yes,tit lebar=yes, resizeable =yes\");") ;
sbOpenWindow.Append("} </script>");
this.Page.RegisterStartupS cript("Ope nWindow", sbOpenWindow.ToString());
Thank you
Here is the code I am using
StringBuilder sbConfirmExit = new StringBuilder();
sbConfirmExit.Append("<scr
sbConfirmExit.Append("wind
sbConfirmExit.Append("var postback = false; function confirmExit() { ");
sbConfirmExit.Append("if(p
sbConfirmExit.Append("even
sbConfirmExit.Append("else
sbConfirmExit.Append("Open
sbConfirmExit.Append(" }</script>");
this.Page.RegisterStartupS
StringBuilder sbOpenWindow = new StringBuilder();
sbOpenWindow.Append("<scri
sbOpenWindow.Append("var NewWindow;");
sbOpenWindow.Append("funct
sbOpenWindow.Append("NewWi
sbOpenWindow.Append("} </script>");
this.Page.RegisterStartupS
Thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.