Marcus L
Marcus L

Reputation: 4080

Onload-script not working in Firefox

I'm writing a customer form, where a drop down menu should be automatically set to the appropriate option if the window.top.document.url is known.

To achieve this I do a <body onload='javascript:init([Generic value])' which calls

function init(value) {
     if (value) {
          document.getElementById('RefererURL').value = window.top.document.URL;
          form1.submit();
       }
   } 

I don't remember why we added the if(value) thing, but the rest is pretty straight forward - get the value, then submit the form to trigger an update that does the actual url-menu mappning.

This solution works in IE, but not in Firefox, and I can't figure out why. I'm suspecting it might have something to do with form1.submit();, but don't understand what or why.

Upvotes: 0

Views: 899

Answers (1)

Paul Whelan
Paul Whelan

Reputation: 16809

try

document.getElementById("form1").submit();

This assumes your form id is 'form1'.

Upvotes: 3

Related Questions