Tuesday, September 13, 2011

Missing closing script tag in html causes javascript runtime error: Object expected

An runtime error: Object expected was returned when testing a simple function in html page's onLoad method. It turns out the error is due to missing closing script tag included
[head]
[script src="testcase.js" /]
[script type="text/javascript"
function callme() {alert("hi");}
[/script]
[/head]
[body onload="callme()"]

After adding the closing tag as shown below, the javascript method callme works properly.

[head]
[script src="testcase.js"] [/script]
[script type="text/javascript"
function callme() {alert("hi");}
[/script]
[/head]
[body onload="callme()"]

John

1 comment: