Forum Moderators: open
I am having some problems calling functions in Firefox:
<html>
<head>
<script language="JavaScript1.2" type="text/JavaScript1.2">
function afunction(){
alert('hello!');
}
</script>
</head>
<body>
<a href="javascript:afunction();">call function</a>
</body>
</html>
This throws 'afunction is not defined' in Firefox, but not IE. Any ideas why?
It's the type
"text/JavaScript1.2"
Your browser doesn't recognise that type attribute (expects "text/javascript"), so the block isn't executed, and afunction doesn't exist.
Better to put no type attribute at all than an incorrect one!