Should I add javascript: before the html tag function?
Possible duplicate:
When do I need to specify the JavaScript protocol?
eg
<body onload="javascript:something();">
in this code, should I put javascript:
?
some of the attatch codes javascript:
,
but some don't.
what is safe and correct?
+2
source to share
3 answers
A better solution would be to avoid using JavaScript explicitly in your markup altogether and use something like jQuery to extract everything into a separate file; you can do something like this:
$(function()
{
// This will be run when the document is loaded.
alert('foo');
$('#some-link').click(function()
{
// This will be run when the element with id `some-link` is clicked.
alert('bar');
});
});
+3
source to share