Scimons #1 Javascript No No.

    Date: 10/11/07 (Javascript Community)    Keywords: browser, html, java

    Thought I'd share this little gem as I randomly sit here waiting to get the energy to leave my desk. Not only should you, as a Javascript coder, know this but you should ensure anyone creating HTML pages that you will later have to add Javascript to should know it as well (bad code monkeys!). It's a simple rule but effective.

    Don't do this . Yup don't use submit buttons.... no wait I meant don't call your submit buttons 'submit'. I mean it's nice and everything to give the button a name, makes the page validate and all, and if the buttons parameter won't be looked at by the server code then what's the problem?

    Now most of you will know the answer but for the rest of you I'll make it nice and simple. Internet Explorer.

    The problem is that Internet Explorers braindead implementation of DOM 0 will overwrite the form.submit(); with your 'submit' button. So when you later in your JS call form.submit(); nothing happens. Well nothing happens in IE, after you've fully tested your code in a proper browser.

    To avoid such things just don't do it. And avoid giving a div the id getElementById while you're at it. Not sure if that would work but I wouldn't be surprised.

    Source: http://community.livejournal.com/javascript/142591.html

« how to hide line || Ok...so weird question for... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home