[web] How to call javascript functions when it is in a .js file?

Started by
1 comment, last by Sander 19 years, 2 months ago
Hi, in my page I want to call a &#106avascript function which resides in a .js file, from some <script> tags But the doAlert() can't be run from inside the script tags below for some reason. Any idea on how to do that?

---------------------
script.js
---------------------
function doAlert() {
alert("hi");
}

-----------------------------------
page.html
-----------------------------------
<html>
<head>
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<script type="text/javascript">doAlert();</script>
</body>
</html>

THanks
Advertisement
Works fine for me... Which browser are you using? I just tried with IE6 and MS FrontPage's built-int "Preview" [which I'm assuming is IE].

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Do you have &#106avascript enabled in your browser? Your example should work.

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

This topic is closed to new replies.

Advertisement