How do I to make a Script avoid being blocked by popup blocker

Giganews Newsgroups
Subject: How do I to make a Script avoid being blocked by popup blocker
Posted by:  Parrot (Parr…@discussions.microsoft.com)
Date: Thu, 30 Oct 2008

I am using the RegisterStartupScript function to dynamically create a script
to display a window from a Calendar control.  The script works only on a
computer which does not have the popup blocker set to On for the browser.  I
don't understand this because I have used the following script hard coded in
another web page and it isn't blocked yet if I use the same script in the
RegisterStartupScript it is blocked.  The script code I used is as follows:

string scriptText = "printWindow = window.open('','','width=400,
height=400');";
scriptText += "printWindow.document.open();";
scriptText += "printWindow.document.write(\"<html><head><body>Some
text</body></html>\");";
scriptText += "printWindow.document.close();";
cs.RegisterStartupScript(this.GetType(), "Testwindow", scriptText, true);

If I change true to false in the RegisterStartupScript argument, nothing
displays at all.  So my question is how can I write the script so it can
bypass a popup blocker?

Dave

Replies