Re: How do I to make a Script avoid being blocked by popup blocker
- From: "Nathan Sokalski" <njsokalski@xxxxxxxxxxx>
- Date: Mon, 3 Nov 2008 15:07:48 -0500
Correct me if I'm wrong, but didn't your original post say you were using
RegisterStartupScript? Using RegisterStartupScript means it is not triggered
by the user, because startup scripts are run when a page is first loaded.
You may have had the user click to trigger a postback, and then the new page
had a startup script, however, that means the user triggered a postback, not
a script. Hopefully this helps, you need to keep in mind the difference
between the user's point of view and the browser's point of view. Good Luck!
--
Nathan Sokalski
njsokalski@xxxxxxxxxxx
http://www.nathansokalski.com/
"Parrot" <Parrot@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E968ED51-ABDB-457E-B213-23ED3A60BF3D@xxxxxxxxxxxxxxxx
Nathan;
Thank you for your suggestion. My original code is initiated by a mouse
click so the script is driven by user input and the popup blocker still
catches it. I will see if I can figure out a way to use the mouseover as
the
trigger rather than a click on trigger.
Dave
"Nathan Sokalski" wrote:
It can depend on how the popup blocker is implemented, but where do you
place the window.open statement? Is it inside script tags? The onload
event
of the body? Putting the window.open method in either of these two places
is
often what triggers the popup blocker to block it. Try this (I don't know
if
it will work or not, but it's worth a try):
Put the window.open in the body or form's onmousemove event. Because you
obviously don't want the popup to popup more than once, place it inside
an
if statement that tests a variable. If the variable is set to true then
call
window.open and set the variable to false so that window.open does not
get
called again. Because onmousemove is something that is intentionally
triggered by the user (the mouse doesn't move itself!), the popup blocker
probably won't be triggered. Maybe some blockers are smarter than this,
but
if I were trying to bypass a blocker this might be the first thing I'd
try.
Good Luck (just don't annoy anyone with the popups)!
--
Nathan Sokalski
njsokalski@xxxxxxxxxxx
http://www.nathansokalski.com/
"Parrot" <Parrot@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:0DCF6AF4-7938-4463-A50F-A047D08D58F5@xxxxxxxxxxxxxxxx
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
.
- References:
- Prev by Date: Opening a SQL Server 2005 Database...
- Next by Date: Re: Opening a SQL Server 2005 Database...
- Previous by thread: Re: How do I to make a Script avoid being blocked by popup blocker
- Next by thread: Invalid handle exceptions always thrown by VS2008
- Index(es):
Relevant Pages
|
Loading