Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Oct 2002
    Location
    São Paulo, BRAZIL
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Netscape problem with <button> tag in mozilla

    Hello folks, i have just a simple page with a form and one <button> tag, this button has a alert( "hello world" ) in its onclick. You can see that after press that button and appear Hello World dialog, the page calls form´s submit. This happen with every button created with <button> tag, Mozilla understad this kind of button as a submit button. Can anyone tell me how would i avoid it?

    Regards,
    LottaLava

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    626
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can we see your code?

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <button type="submit">..</button> should do it
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #4
    New Coder
    Join Date
    Oct 2002
    Location
    São Paulo, BRAZIL
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don´t want its button to submit my page. To do that i created a method that check if user´s browser is Mozilla and change button´s property.

    The code is pretty simple, checkout:

    <html>
    <head>
    <script language="JavaScript">
    function test( )
    {
    alert( "They are camming." );
    }
    </script>
    </head>
    <body>
    <form name="frmMain"
    method="POST"
    action="http://localhost/blah">
    <button name="btBlah" onClick="test( );">Test</button>
    </form>
    </body>
    </html>

  • #5
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Try the input tag...

    <input type="button" value="Test" name="btBlah" onClick="test( );">
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #6
    Regular Coder
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    487
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    function test (text) {
        alert(text);
        return false;
    }
    
    ...
    
    <button onclick="return test('blah');">Button!</button>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •