garethhall Posted February 12, 2010 Share Posted February 12, 2010 I have the code below and works fine in firefox ans safari but I get an IE error. Can you guys tell me way? As far as I can tell the error is caused by appendChild() Many thanks <script type="text/javascript"> var theNo = Math.floor(Math.random()*9999); var spm = document.createElement('input'); spm.setAttribute('type','hidden'); spm.setAttribute('name','spamHidden'); spm.setAttribute('id','spamHidden'); spm.setAttribute('value',theNo); document.getElementById('frm').appendChild(spm); </script> Quote Link to comment Share on other sites More sharing options...
bibby Posted February 13, 2010 Share Posted February 13, 2010 It's possible that the script is running before the form has finished closing ( /form ). IE doesn't much like appending child elements to one that's currently in the process of being written. Try moving the script after /form Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.