The onclick event in the anchor tag does not work in IE

It works fine on Firefox and Chrome, but IE 8 will not call the submit () method when the binding link is clicked.

<a href="javascript:void(0);" onclick="submit();">Sign In</a>

The sending method is defined on the same page as follows:

<head>
<script type="text/javascript">

function submit()
{
// other code                                              
document.forms[0].submit();
}  

</script>
</head>
+5
source share
4 answers

Can you provide a little more context? For example, where and how is a function defined submit? With the help of just described above, it should work - with the exception of:

You might also want return false;to undo the default action. For instance:.

<a href="javascript:void(0);" onclick="submit();return false;">Sign In</a>

Perhaps the default action occurs immediately after submitand intervenes in it.

. submit. IE . - id name, "", , ...

+7

, , IE 11, . , , , , Javascript ( ).

, cog " ". , โ€‹โ€‹ " ".

+1

Try using

<a onclick="submit();">Sign In</a>

or

<a href="javascript:submit();">Sign In</a>
0
source

If you need to enter a value in a javascript function, make sure that a single quote is used instead of a double quote.

For instance:

<a href="#" onclick="your_function('input');">Sign In</a>
0
source

All Articles