Firefox inappropriately blocks (as a "popup") a form submission usingjavascript on a web page I'm de

D

dkomo872

I'm not sure this is the right forum for this problem, but maybe
someone here has encountered a similar problem and can offer a
suggestion. I'm developing a web page using Firebug with Firefox.
When I execute the following Javascript statement:

document.form3.submit();

Firefox comes up with a message saying that it blocked a popup
window. This statement does not open a popup window! It causes a
link to a new browser window on a separate web page. I have done this
type of form submission many times in other web pages I've developed
with no problem.

I hit this popup blocking whether or not I have Firebug open.

I can of course allow the "popup" by changing Firefox options. When I
do, the form submission works fine, and it works fine in Internet
Explorer, which doesn't block popup windows. But this is not a
solution to my problem because users of my web page using Firefox will
hit the same problem.
 
E

Erwin Moller

dkomo872 schreef:
I'm not sure this is the right forum for this problem, but maybe
someone here has encountered a similar problem and can offer a
suggestion. I'm developing a web page using Firebug with Firefox.
When I execute the following Javascript statement:

Hi,

document.form3.submit();

Clearer would be:
document.forms["form3"].submit();
or
document.forms.form3.submit();
Firefox comes up with a message saying that it blocked a popup
window. This statement does not open a popup window! It causes a
link to a new browser window on a separate web page.

What do you say excactly?
"It causes a 'link' to a new browser window on a seperate web page?"
I have no clue what that means.

Are you saying maybe that the form has a target="somewindow"?
If so, that is also a 'popup'.
A popup is nothing more than a new window.


I have done this
type of form submission many times in other web pages I've developed
with no problem.

If all else was the same: Possibly a different FF version/settings?
I hit this popup blocking whether or not I have Firebug open.

I can of course allow the "popup" by changing Firefox options. When I
do, the form submission works fine, and it works fine in Internet
Explorer, which doesn't block popup windows. But this is not a
solution to my problem because users of my web page using Firefox will
hit the same problem.

That is a problem if you want to open new windows.
Could you simply inform your users to allow popups for your site? That
is why the easy option exists in FF. (Just 2 clicks).

Good luck!

Regards,
Erwin Moller


--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
 
D

dkomo872

dkomo872 schreef:
I'm not sure this is the right forum for this problem, but maybe
someone here has encountered a similar problem and can offer a
suggestion.  I'm developing a web page using Firebug with Firefox.
When I execute the following Javascript statement:
Hi,

document.form3.submit();

Clearer would be:
document.forms["form3"].submit();
or
document.forms.form3.submit();
Firefox comes up with a message saying that it blocked a popup
window.  This statement does not open a popup window!  It causes a
link to a new browser window on a separate web page.

What do you say excactly?
"It causes a 'link' to a new browser window on a seperate web page?"
I have no clue what that means.

Are you saying maybe that the form has a target="somewindow"?
If so, that is also a 'popup'.
A popup is nothing more than a new window.

The form has target="_blank".

Firefox does not block all pop ups. It has the ability to distinguish
between user-requested pop ups and non-user-requested pop ups. That's
why normal form submissions can open a new window without being
blocked. These are submissions where the user clicks on the Submit
button.

Apparently FF thinks my "document.form3.submit()" statement causes a
non-user-requested pop up. I need to find a way to fool FF.
   I have done this


If all else was the same: Possibly a different FF version/settings?

No. I upgraded yesterday to FF 3.5.2. It made no difference to the
pop up blocking problem.
That is a problem if you want to open new windows.
Could you simply inform your users to allow popups for your site? That
is why the easy option exists in FF. (Just 2 clicks).

Not a very clean solution.
 
E

Erwin Moller

dkomo872 schreef:
On Aug 26, 2:01 am, Erwin Moller

The form has target="_blank".

Firefox does not block all pop ups. It has the ability to distinguish
between user-requested pop ups and non-user-requested pop ups. That's
why normal form submissions can open a new window without being
blocked. These are submissions where the user clicks on the Submit
button.

I wonder how FF knows where a request to do a, for example,
window.open() came from.
Are you sure about that?
How does that actually work?
Apparently FF thinks my "document.form3.submit()" statement causes a
non-user-requested pop up. I need to find a way to fool FF.

You can try to open a window via window.open(), then target that new
window with you target="" in the form by its name.
Not sure. Give it a shot.

Good luck.
Regards,
Erwin Moller

--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
 
D

dkomo872

dkomo872 schreef:






I wonder how FF knows where a request to do a, for example,
window.open() came from.
Are you sure about that?
How does that actually work?

If the user clicks on some control inside the window causing a new
window to open, FF knows that's a user-requested pop up.

Write a little Javascript routine to execute window.open() when a
button is clicked if you don't believe me.
You can try to open a window via window.open(), then target that new
window with you target="" in the form by its name.
Not sure. Give it a shot.

This doesn't work for form submissions because the data in the form
doesn't get sent to the server.
 
E

Erwin Moller

dkomo872 schreef:
If the user clicks on some control inside the window causing a new
window to open, FF knows that's a user-requested pop up.

Write a little Javascript routine to execute window.open() when a
button is clicked if you don't believe me.

Nah, don't feel like it right now.
And I didn't tell you I didn't believe you: I asked you how FF
differentiates between user action and not-user actions.

I can think something up, like it checks if a mouseclick was involved
in the event, but that is pure speculation, hence my question.

This doesn't work for form submissions because the data in the form
doesn't get sent to the server.

No server?
So you have a form with target="_blank". What is the value for action in
that form?
That doesn't make a lot of sense at first sight.

What do you expect that will load in that window?
In case you are going to fill the new window via JS, why not open it
with window.open()?

You might consider giving a little more information...

Erwin Moller


--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
 
D

dkomo872

dkomo872 schreef:






Nah, don't feel like it right now.
And I didn't tell you I didn't believe you: I asked you how FF
differentiates between user action and not-user actions.

I can think something up, like it checks if a mouseclick was involved
in the event, but that is pure speculation, hence my question.





No server?
So you have a form with target="_blank". What is the value for action in
that form?
That doesn't make a lot of sense at first sight.

Why not? It's a common ordinary form submission with method="post".
It sends the form data to a PHP script on the server which then
creates a report based on what the user filled out in the form.

<form name="form3" id="form2" action="foobar.php" method="post"
target="_blank">
What do you expect that will load in that window?

The report created by the PHP script foobar.
In case you are going to fill the new window via JS, why not open it
with window.open()?

Because the the method="post" won't happen! There are a dozen fields
of information that need to be sent to the PHP script.
 
E

Erwin Moller

dkomo872 schreef:
Why not? It's a common ordinary form submission with method="post".
It sends the form data to a PHP script on the server which then
creates a report based on what the user filled out in the form.

<form name="form3" id="form2" action="foobar.php" method="post"
target="_blank">

Hi,

I know how forms and PHP work. I do that the whole day. ;-)

You wrote:
"This doesn't work for form submissions because the data in the form
doesn't get sent to the server."

What made me think you were not intending to send to a server.
The report created by the PHP script foobar.
Good.


Because the the method="post" won't happen! There are a dozen fields
of information that need to be sent to the PHP script.

Indeed.

Now we got that cleared up: Did you try my suggestion I wrote earlier?
Erwin: You can try to open a window via window.open(), then target that
new window with you target="" in the form by its name.

dkomo972: This doesn't work for form submissions because the data in the
form doesn't get sent to the server.

What makes you think that won't work?
Why will the form not be submitted to the server?
You might want to reread what I wrote.

You can open a window with window.open().
Give it a name (second argument for window.open()).
Then use that name as the target in your form.

Erwin Moller

--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
 
D

dkomo872

dkomo872 schreef:






Hi,

I know how forms and PHP work. I do that the whole day. ;-)

You wrote:

"This doesn't work for form submissions because the data in the form
doesn't get sent to the server."

What made me think you were not intending to send to a server.






Indeed.

Now we got that cleared up: Did you try my suggestion I wrote earlier?
Erwin: You can try to open a window via window.open(), then target that
new window with you target="" in the form by its name.

dkomo972: This doesn't work for form submissions because the data in the
form doesn't get sent to the server.

What makes you think that won't work?
Why will the form not be submitted to the server?
You might want to reread what I wrote.

You can open a window with window.open().
Give it a name (second argument for window.open()).
Then use that name as the target in your form.

Without executing "document.form3.submit()"? This statement will cause
an immediate block by the pop up blocker.

Actually, I think window.open() will be blocked as well FF has lost
track of the original mouse click that triggered all this action.
 
E

Erwin Moller

dkomo872 schreef:
Without executing "document.form3.submit()"? This statement will cause
an immediate block by the pop up blocker.

Better would be: document.forms.form3.submit();

So basically you are saying Javascript is not allowed to open new
windows with the default popup blocker active in FF?

I made this simple page:

<html>
<head>
<title>blockuptest</title>
</head>
<body>
Hi, click <span onClick="dopopup();" style="color:#00F;">here</span> for
popup.
<script type="text/javascript">
function dopopup(){
window.open("http://www.google.com","googlewindow");
}
</script>
</body>
</html>

My popupblocker in FF is active, I have no exceptions listed.
I uploaded it to my server, and tested there.
It simply opens google in a new window, no questions asked, when I click
'here'.

So I ask you again: Did you TRY it actually or do you simply assume it
won't work?

Erwin Moller

--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
 
D

dkomo872

dkomo872 schreef:





Better would be: document.forms.form3.submit();

So basically you are saying Javascript is not allowed to open new
windows with the default popup blocker active in FF?

No, that's not what I said. User-requested pop ups will work fine.
I made this simple page:

<html>
<head>
  <title>blockuptest</title>
</head>
<body>
Hi, click <span onClick="dopopup();" style="color:#00F;">here</span> for
popup.
<script type="text/javascript">
  function dopopup(){
        window.open("http://www.google.com","googlewindow");      
  }
</script>
</body>
</html>

My popupblocker in FF is active, I have no exceptions listed.
I uploaded it to my server, and tested there.
It simply opens google in a new window, no questions asked, when I click
'here'.

Of course. You have created a user-requested pop up because FF knows
that you (the user) have done a click in the window to open the pop up
window. window.open() is not the relevant reason for why it works.
So I ask you again: Did you TRY it actually or do you simply assume it
won't work?

Ok, if it makes you happy, I'll execute 'window.open("http://
www.google.com","googlewindow");' in place of my
' document.form3.submit();' and see if gets blocked.
 
D

dkomo872

dkomo872 schreef:





So basically you are saying Javascript is not allowed to open new
windows with the default popup blocker active in FF?

I made this simple page:

<html>
<head>
  <title>blockuptest</title>
</head>
<body>
Hi, click <span onClick="dopopup();" style="color:#00F;">here</span> for
popup.
<script type="text/javascript">
  function dopopup(){
        window.open("http://www.google.com","googlewindow");      
  }
</script>
</body>
</html>

My popupblocker in FF is active, I have no exceptions listed.
I uploaded it to my server, and tested there.
It simply opens google in a new window, no questions asked, when I click
'here'.

So I ask you again: Did you TRY it actually or do you simply assume it
won't work?

Ok, I executed

window.open("http://www.google.com","googlewindow");

in place of my

document.form3.submit();

and got the usual

"Firefox prevented this site from opening a pop-up window" message at
the top of the browser window.
 
E

Erwin Moller

dkomo872 schreef:
Ok, I executed

window.open("http://www.google.com","googlewindow");

in place of my

document.form3.submit();

and got the usual

Bad luck.

I tested it too with a window.setTimeout(), and then it gets blocked too.
However, I was inspired by your remark about clientactions not getting
blocked, so I tried the following:

<html>
<head>
<title>blockuptest</title>
</head>
<body>
Hi, click <span onClick="window.setTimeout('dopopup();',100);"
style="color:#00F;">here</span> for popup.

<script type="text/javascript">
function dopopup(){
window.open("http://www.google.com","googlewindow");
}
</script>
</body>
</html>

Which doesn't get blocked.

-----------------------------------------------

However, this version DOES get blocked after the first window:

<html>
<head>
<title>blockuptest</title>
</head>
<body>
Hi, click <span onClick="window.setTimeout('dopopup();',100);"
style="color:#00F;">here</span> for popup.

<script type="text/javascript">
var count=0;
function dopopup(){
window.open("http://www.google.com","googlewindow"+count);
count++;
window.setTimeout('dopopup();',1000);
}
</script>
</body>
</html>

So appearantly FF needs a fresh useraction, otherwise it will start
blocking again.

-----------------------------------------------
Last silly test, It will invoke the popup on every mouseclick, and that
does work.

<html>
<head>
<title>blockuptest</title>
</head>
<body onClick="postingtime(event);">
Hi, click <span onClick="window.setTimeout('dopopup();',100);"
style="color:#00F;">here</span> for popup.

<script type="text/javascript">
function postingtime(evt){
var meetingdkomo872criteria = Math.random()<0.9;
if (meetingdkomo872criteria){
dopopup();
}
}

function dopopup(){
window.open("http://www.google.com","googlewindow"+Math.random());
}
</script>
</body>
</html>

I tried with onMouseMove() too, but that DOESN'T work.

--------------------------------------------------

Maybe you can use the last hack, allthough I personally think it stinks
hard. (I just wrote it our of curiousity.)
It depends on what it is excactly that triggers your formsubmission (you
didn't tell yet) if such an approach is feasable.
Personally I would simply tell my clients that you need to popup, and
tell them to unblock it for your site.

I go home now.
Maybe somebody else has some brighter ideas. ;-)
Good luck.

Erwin Moller

--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
 
D

dkomo872

dkomo872 schreef:






Bad luck.

I tested it too with a window.setTimeout(), and then it gets blocked too.
However, I was inspired by your remark about clientactions not getting
blocked, so I tried the following:

Did you try a <body onload='window.open("http://
www.google.com","googlewindow");'> yet?
<html>
<head>
  <title>blockuptest</title>
</head>
<body>
Hi, click <span onClick="window.setTimeout('dopopup();',100);"
style="color:#00F;">here</span> for popup.

<script type="text/javascript">
  function dopopup(){
        window.open("http://www.google.com","googlewindow");      
  }
</script>
</body>
</html>

Which doesn't get blocked.

I'm not surprised.
-----------------------------------------------

However, this version DOES get blocked after the first window:

<html>
<head>
  <title>blockuptest</title>
</head>
<body>
Hi, click <span onClick="window.setTimeout('dopopup();',100);"
style="color:#00F;">here</span> for popup.

<script type="text/javascript">
var count=0;
  function dopopup(){
        window.open("http://www.google.com","googlewindow"+count);
        count++;
        window.setTimeout('dopopup();',1000);
  }
</script>
</body>
</html>

So appearantly FF needs a fresh useraction, otherwise it will start
blocking again.

I read somewhere that FF's blocker actually counts the number of
clicks in some interval, and if there are too many, it will block.
Thus an impatient user who clicks multiple times on some control due
to a slow web site will get blocked.
-----------------------------------------------
Last silly test, It will invoke the popup on every mouseclick, and that
does work.

<html>
<head>
  <title>blockuptest</title>
</head>
<body onClick="postingtime(event);">
Hi, click <span onClick="window.setTimeout('dopopup();',100);"
style="color:#00F;">here</span> for popup.

<script type="text/javascript">
function postingtime(evt){
        var meetingdkomo872criteria = Math.random()<0.9;
        if (meetingdkomo872criteria){
                dopopup();
        }

}

function dopopup(){
        window.open("http://www.google.com","googlewindow"+Math.random());
  }
</script>
</body>
</html>

I tried with onMouseMove() too, but that DOESN'T work.

--------------------------------------------------

Maybe you can use the last hack, allthough I personally think it stinks
hard. (I just wrote it our of curiousity.)
It depends on what it is excactly that triggers your formsubmission (you
didn't tell yet) if such an approach is feasable.

I didn't tell because I didn't want to scare off people who might come
up with a simple workaround. But here's the full story: the
"document.form3.submit()" gets executed inside the callback function
of an Ajax request. The Ajax request is triggered by clicking on a
button, but I think the FF pop up blocker loses track of the click
because the callback function gets executed asynchronously. That's
why the form submit gets blocked.

Elsewhere in the web page, document.form3.submit() works without a
hitch because it isn't part of an Ajax request.
Personally I would simply tell my clients that you need to popup, and
tell them to unblock it for your site.

I go home now.

Yeah, I have go too.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top