Toofaan Baba
Toofaan Baba

Reputation: 11

External javascript file in html not working

first post.. trying javascript for first time. i am following a book , created two files in the same directory test_js.html helloWorld.js

Contents of both are below: test_js.html

<html>
<head>
<title> First Javascript page </title>
<script type="text/javascript" src="helloWorld.js"></script>
</head>
<body></body>
</html>

helloWorld.js

<script type="text/javascript">
alert("hello");
</script>

I dont see any alert when i load the html page. However if i embed the same alert("hello") in the html page, i am seeing the alert being displayed.

Tried this on chrome and firefox (both latest) with same result. Following googled examples is not showing any error in any of the files.

Please help.

Upvotes: 0

Views: 92

Answers (1)

Sultan Aslam
Sultan Aslam

Reputation: 6238

remove script tags from helloWorld.js

just

alert("hello");

Upvotes: 4

Related Questions