Google Chrome

Discussion in 'JavaScript' started by NoamBarz, Sep 16, 2008.

  1. #1
    I am currently adjusting my website to Google Chrome.
    While working on it, I noticed something weired.
    As part of the site, I use HTML buttons and I run different functions when people click them. What I noticed is that when I click the buttons, they go to the function I assigned, but try to submit the form after that. This only happens in Chrome (maybe in Safari, but I didn't check). This unintended reaction ruins my functionality.

    Has this happened to anyone? is there a way to overcome the problem?
     
    NoamBarz, Sep 16, 2008 IP
  2. NoamBarz

    NoamBarz Active Member

    Messages:
    242
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #2
    OK, I took care of it. All you need to do is use "return false" after calling the function.

    For example: <input type='button' value='check' onclick='javascript:doThis(); return false;' />
     
    NoamBarz, Sep 16, 2008 IP
  3. xlcho

    xlcho Guest

    Messages:
    532
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Weird! You sure these are buttons and not submits ?! Returning false is used when you don't wanna submit a form via <input type='submit'. I haven't got any problems with <input type='button'... in Chrome.
     
    xlcho, Sep 16, 2008 IP