Alex
Alex

Reputation: 1973

Javascript code does not work in Firefox

In the image click I write code for invoke java like this

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
        <title>New Page 1</title>
    </head>
    <body>
        <table cellpadding="0" cellspacing="0" width="311">
            <tr>
                <td height="14">
                    <img onclick ="SignIn();" border="0" src="../images/Sign_In.gif" width="80" height="28">
                </td>
            </tr>
        </table>
        <script type="text/javascript" language="JavaScript">
            function SignIn(){
                alert();
            }
        </script>
    </body>
</html>

The above code is working fine in Internet Explorer, but not in FireFox. What is the problem?

Upvotes: 1

Views: 1020

Answers (4)

madcolor
madcolor

Reputation: 8170

Try this:

{ alert(); document.getElementById('FormSignIn').submit(); } 

Documentation: document.getElementById

Upvotes: 6

mikabuka
mikabuka

Reputation: 222

I got this problem now. Fixed by cleaning cache in firefox : Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"

Upvotes: 0

Cleiton
Cleiton

Reputation: 18153

Here is an exemple of what you should always do when validating web forms with javascript:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
        <title>New Page 1</title>
    <!-- Inline javacript should be always inside header tag -->
    <script type="text/javascript">
    function SignIn(){
        alert("");//In firefox you have to pass something to alert to make it work


        //More code logic you can put here

        //...
        //If everything is ok return TRUE to
        //post data to "somepage.aspx" if
        // dont return FALSE and do nothin
        if(everythingIsOk);
            return true;
        else
            return false;   
    }
    </script>
    </head>
    <body>
        <form method="post" action="somepage.aspx">
            <table cellpadding="0" cellspacing="0" width="311">
                <tr>
                    <td height="14">
                        <input type="image" src="../images/Sign_In.gif" width="80" height="28" onclick="return SignIn();">
                    </td>
                </tr>
            </table>
        </form>
    </body>
</html>

Upvotes: 1

Chetan S
Chetan S

Reputation: 23823

You need to pass an argument to alert. Seems firefox doesn't like it when you don't while IE shows a blank alert.

alert("text here");

Upvotes: 2

Related Questions