| | |
Javascript fails in Firefox
Please support our JavaScript / DHTML / AJAX advertiser: 50% Off 6 Months Web Hosting from 1&1. The World's #1 Host!
![]() |
•
•
Join Date: Jun 2005
Posts: 92
Reputation:
Solved Threads: 0
I can run the following javascript code succefully in IE browser:
<script language="JavaScript" type="text/JavaScript">
document.formname.submit();
</script>
this javascript automatically submit the form when running the page.
However I have problem in Firefox browser, it's stuck at this code (cannot submit form).
Any idea what I need to modify so it works both on IE and Firefox? thanks.
<script language="JavaScript" type="text/JavaScript">
document.formname.submit();
</script>
this javascript automatically submit the form when running the page.
However I have problem in Firefox browser, it's stuck at this code (cannot submit form).
Any idea what I need to modify so it works both on IE and Firefox? thanks.
IE can use the forms name element to identify the form. I hope that the same is not true for firefox. but I think in firefox and IE you can use the forms ID attribute ( the form should still have a name!! ).
I prefer to use this technique:
This technique should work on all browsers that have JavaScript enabled.
I prefer to use this technique:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
var formToSend = document.getElementById("formId"); formToSend.submit();
This technique should work on all browsers that have JavaScript enabled.
I know this is over a year old, but I'd like to update the response for any googlers. The following will work in all major browsers:
OR
Again, either code will work, and it's preferable to keep your code clean by removing unnecessary code/lines (like where the previous poster created a variable and then submitted that variable).
document.formname.submit(); where "formname" is the same as the form's "name" attribute.OR
document.getElementById('formid').submit(); where "formid" is the same as the form's "id" attribute.Again, either code will work, and it's preferable to keep your code clean by removing unnecessary code/lines (like where the previous poster created a variable and then submitted that variable).
Hi,
I think alpha_foobar has written code in more cleaner way than joequincy. Its always better to declare variable and gave them good name so that it can understand by others.
formToSend.submit(); is more meaningfull than documnt.getElementById(formid).submit();
Always write code so that anyone can understand it easily.
I think alpha_foobar has written code in more cleaner way than joequincy. Its always better to declare variable and gave them good name so that it can understand by others.
formToSend.submit(); is more meaningfull than documnt.getElementById(formid).submit();
Always write code so that anyone can understand it easily.
When you think you have done a lot, then be ready for YOUR downfall.
![]() |
Similar Threads
- javascript in mozilla firefox (JavaScript / DHTML / AJAX)
- Javascript not working in Firefox (JavaScript / DHTML / AJAX)
- Why javascript does not work on firefox? (JavaScript / DHTML / AJAX)
- Javascript not working in Firefox (JavaScript / DHTML / AJAX)
- How to correct this javascript UNDER Mozilla Firefox? (JavaScript / DHTML / AJAX)
- Javascript problem in FIREFOX (JavaScript / DHTML / AJAX)
- Javascript Problem with Firefox (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Code to populate pages with multiple artists?
- Next Thread: template management of the website
Views: 14976 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
8 ad ajax ajaxcode ajaxhelp ajaxjspservlets animate api array asp autoplay box boxes bug captchaformproblem card catch close code codingproblem content cookies css date debug dependent design dialog div dom draganddrop dynamic element embed engine error eventhandlers events explorer ext file firefox firehose flash focus font form forms function gears google gxt hide html ie7 iframe image image() internet internet-explorer java javascript javascripts jquery js libcurl lists load maps modal mysql onclick onmouseover parameters php player position post resize reveal script scroll scrubber search select show size smarty source text textbox twitter unicode validation variables web webkit window xml \n





