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.docume开发者_Python百科nt.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.
try
document.getElementById("form1").submit();
This assumes your form id is 'form1'.
精彩评论