Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1248 Why do I get a strange error on a page with both javascript and vbscript?

irt.org | Knowledge Base | JavaScript | Bugs | Q1248 [ previous next ]

Q1248 Why do I get a strange error on a page with both javascript and vbscript?

Affects: Internet Explorer 4.x 4.x

Errors such as "end of statement expected" and "cannot use parens"

They appear if you have a VBScript in the head BEFORE a JavaScript and then call the JavaScript function from a handler in the page. It is due to Internet Explorer setting the default scripting language to VBScript and then it gets JavaScript in a handler instead.

Solution: Add LANGUAGE="JavaScript" to the tag in question.

<html> 
<head> 

<script language="VBScript"><!-- // 
Sub Test() 
   Rem Nothing 
End Sub 
// --></script>

<script language="JavaScript"><!-- // 
function myFunction() { 
   alert('Ok');
   return true; 
} 
// --></script> 

</head>

<body> 

<script language="JavaScript"><!-- // 
myText = '<a href="javascript:;" language="JavaScript" onclick="myFunction();">Hello</a>'; 
document.writeln(myText); 
//--></script> 

</body> 
</html> 

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.