What is the difference between the following statements?
<tr onclick="javascript:class1.function1()">
<td>HideAlert</td>
</tr>
and
<tr onclick="class1.function1()">
<td>HideAlert</td>
</tr>
I created a webpage with the second method for calling the function and tested in Internet Explorer 6.0 which came with Windows 2003 Server. The function is not called. When i gave “javascript:class1.function1()” in the browsers addressbar, then the function worked. Is there any difference in calling the function with the above mentioned ways?
The script is like below:
<script type="text/javascript">
var class1 = function(obj) {
this.val1 = obj.val1;
}
class1.function1 = function() {
$('#alertDiv').fadeOut('slow', function() {
});
</script>
The jquery version is 1.4.2
In the address bar (or in an
hrefattribute, or anywhere else a regular URL might go),javascript:is the protocol that identifies a piece of JavaScript to be run in the current page.In an
onclickattribute (or any other script context),javascript:is a label which may be used like this:In other words,
onclick="javascript:..."is unnecessary.