Sign in to follow this  
johnnyBravo

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

Recommended Posts

johnnyBravo    100
Hi, in my page I want to call a javascript 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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this