views:

291

answers:

3

hi friends,

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 working fine in Internet Explorer but not in FireFox. What is the problem?

+6  A: 

Try this

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

https://developer.mozilla.org/en/DOM/document.getElementById

madcolor
+1, but document.FormSignIn references a form with name='FormSignIn', whereas getElementById() will of course look for an id='FormSignIn'. This is right, but he may also need to change the html.
Joel Coehoorn
Right.. I make an assumption based on the limited info.. Indeed.
madcolor
Oi.. <img onclick='javascript: myfunction("thisImageId");'>, put your Javascript in the HEAD
madcolor
i try with this code ,this code is workingbut alert not working<html><head><title>getElementById example</title><script type="text/javascript">function changeColor(newColor){ elem = document.getElementById("para1"); elem.style.color = newColor; alert();}</script></head><body><p id="para1">Some text here</p><button onclick="changeColor('blue');">blue</button><button onclick="changeColor('red');">red</button></body></html>
Alex
Since this question has completely changed, I shall bow out. I believe [Chetan] has the solution. Ask yourself.. What am I trying to ALERT(?)?
madcolor
+2  A: 

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");
Chetan Sastry
hi tks, this is working.But i try to pass value to the document, document.getElementById("para1").innerText="text here"; this is not working
Alex
innerText isn't supported by Firefox. Use innerHTML.
Chetan Sastry
in each element in firefox we use "ID"? to passing and retrive values, as like xhtml?
Alex
+1  A: 

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>
Cleiton
document.getElementById("para1").value="text here"; this command is also not working, why?
Alex
in each element in firefox we use "ID"? to passing and retrive values, as like xhtml?
Alex