22 February 2011

call function with parameter from external javascript file

I discover something interesting recently.

Many beginners already know that but for some unknown reason quite often forgot about it.
 Apparently, many people  have a weird problem with  ... call function with parameter from external javascript file.
 Some solutions are quite confusing, so here you can find  easiest solution :

our html file looks:

<html>
<head>
<script type="text/javascript" src="js/message.js"></script>
</head>
 <body>

 <script type="text/javascript">
showMessage("This message is sent as parameter")
 </script>

 </body>
</html>

our js file looks:

function showMessage(text) {
alert(text);
}


 That's it.