Calls to differing JavaScript functions that submit a form to an "external" target only submits form for first function called and other submits seem to be ignored

NEW
Unassigned

Status

()

Core
DOM
P5
major
10 years ago
24 days ago

People

(Reporter: Matthew Dirks, Unassigned)

Tracking

1.9.2 Branch
x86
Windows XP
Points:
---
Bug Flags:
blocking1.9.2 -

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

10 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3

Details of problem copied and slightly modified from my post to another forum (source: http://forums.somethingawful.com/showthread.php?threadid=2983507&pagenumber=1&perpage=40#post350968736 ) :

I have some JavaScript functions being dynamically generated by PHP which populates the values of a "hidden" form (form consisting solely of hidden values) on one page and submits this form data to a separate page. This form's target is set to "_blank" so that it posts into a new window/tab and leaves the originating tab/window untouched by the process. Once this second page loads it's post data will be automatically posted yet again to a 3rd page. The first 2 pages are on the same server, the 3rd is on an external site. The generated scripts are called by placing them in the "onload" parameter of the page's body tag as PHP generates the page.

The problem that I face is that I have need to submit the first form multiple times with different values and while my code works as expected in IE7 and Chrome, it falls short in Firefox (only does one submit and stops).

Relevant code and markup follow (note some variable names changed for generalization purposes):

JS Function that sets all forms and anchor links to external targets if they have the "external" class defined, also PHP code inserts dynamically created JS functions:

code:
function externalLinks() { if (document.getElementsByTagName) { var anchors = document.getElementsByTagName("a"); for (var i=0; i < anchors.length; i++) { var anchor = anchors[i]; if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") { anchor.target = "_blank"; } } var forms = document.getElementsByTagName("form"); for (var i=0; i < forms.length; i++) { var form = forms[i]; if (form.getAttribute("action") && form.className == "external") { form.target = "_blank"; } } } } <?php foreach ($ADDITIONAL_JSCRIPTS as $script){ echo ($script . "\n") ; } ?>


Body tag where generated JS functions will be called:
code:
<body onload="externalLinks();<?php echo ($BODY_ONLOAD_STRING); ?>">

Form that is to be posted multiple times to multiple new windows:
code:
<form id="ExportForm" action="export.php" method="post" class="external"> <div id="ExportHiddenFields" class="hiddenFields"> <input type="hidden" name="foo" id="foo" value="" /> <input type="hidden" name="bar" id="bar" value="" /> </div> </form>


PHP code that generates the necessary JS functions and, indirectly, calls them:
(additional note: the setupValidation function just checks that a given field in the main, "non-hidden" form is filled in before it is submitted, it does not effect the hidden form)
code:
$do_export = (is_array($export_array) && !(empty($export_array))); $ADDITIONAL_JSCRIPTS = array(); if ($do_export) { foreach ($export_array as $row_key => $row_array) { $ADDITIONAL_JSCRIPTS[] = (' function InfoSubmit' . $row_key . '(){ var frm; frm = document.getElementById("ExportForm"); frm.foo.value = "'.preg_replace('/"/', '"', $row_array['foo']).'"; frm.bar.value = "'.preg_replace('/"/', '"', $row_array['bar']).'"; frm.submit(); return true; } '); } } $BODY_ONLOAD_STRING .= 'setupValidation();'; if ($ops_export) { foreach ($export_array as $row_key => $row_array) { $BODY_ONLOAD_STRING .= 'InfoSubmit' . $row_key . '();'; } }


As I mentioned before, this works properly in IE7 and Chrome (multiple new tabs/windows open), so I know the code is being generated properly. It's just, for some reason , Firefox will not go past the first function that calls submit(). Is there something in my script I need to tweak so that the JavaScript interpretor will open multiple new windows/tabs in Firefox as it does in IE7 and Chrome ... or is this an actual bug in the JS interpreter?

Reproducible: Always

Steps to Reproduce:
1.Have/put necessary code in place to submit differing posts to multiple new tabs/widows.
2.Run test code.
3.If prompted, allow submissions (if non-secure submission)
Actual Results:  
Only one new tab will open and submit it's form values.

Expected Results:  
Multiple tabs should open. One for each form submitted to a new page and each submitting the values it set to the form's specified action page.

Firefox's JavaScript Interpreter needs to better allow for this kind of multiple submit call. I set the severity as "Major" because submit() is a pretty key function and while this particular style of submission probably isn't used often, it's worrisome enough to wonder how else calls to submit aren't going to operate as one would expect (especially when it works in other browsers that aren't IE and in IE (as messed up as IE's implementation may be)).
(Reporter)

Comment 2

10 years ago
This bug persists in 3.0.4.
(Reporter)

Updated

10 years ago
Summary: Calls to differing JavaScript functions that submit and "external" form only submits form for first function called and other submits seem to be ignored → Calls to differing JavaScript functions that submit a form to an "external" target only submits form for first function called and other submits seem to be ignored
(Reporter)

Comment 3

10 years ago
This bug persists in 3.0.5 and 3.0.6.
(Reporter)

Comment 4

9 years ago
This bug persists in 3.0.10.
(Reporter)

Comment 5

9 years ago
This bug persists in 3.5.2
Flags: blocking-firefox3.6?
Priority: -- → P2
--> Core::JavaScript Engine
Assignee: nobody → general
Component: General → JavaScript Engine
Flags: blocking-firefox3.6?
Product: Firefox → Core
QA Contact: general → general
Version: unspecified → 1.9.2 Branch
jst, this might actually be more with forms; can you look, too?
Flags: blocking1.9.2?
This is probably not JS engine. I don't think this should block, but I'll leave it up to jst.
Assignee: general → nobody
Component: JavaScript Engine → DOM
QA Contact: general → general
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: blocking1.9.2? → blocking1.9.2-
(Reporter)

Comment 9

8 years ago
This bug persists in 3.6.3 ... in case you were wondering ;-)
(Reporter)

Comment 10

7 years ago
Bug is still present in (the otherwise spectacular) Firefox 4.0.
(Reporter)

Comment 11

7 years ago
Bug is still present as of Firefox 9.0.1.
Mounir, can you look at this?
(Reporter)

Comment 13

6 years ago
Just tested again in Firefox 14.0.1 ... still there. 

Interesting side-note is that it also seems to be a problem in Google Chrome now as well (version 20.0.1132.57).
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046

Move all DOM bugs that haven't been updated in more than 3 years and has no one currently assigned to P5.

If you have questions, please contact :mdaly.
Priority: P2 → P5
You need to log in before you can comment on or make changes to this bug.