Is there a way to call a function in another HTML file? Thanks.
Printable View
Is there a way to call a function in another HTML file? Thanks.
I don't think you can call a function from mixed files such as HTML; but a simple solution would be to write your javascript functions into seperate, javascript only text files (usually with the extension ".js"). Then, you insert the script files into any page, using empty <script> tags with the src attribute set - like so:
<script language="javascript" src="test.js"></script>
Then, if I wanted to say, call the "example()" function from that external file, I could just use the normal method wherever I liked in the document (provided that it is after the <script> being loaded, and later on in the document.)
P.S: The tags must be empty - that means only <script src=""></script>, without any inner Javascript. (you do any other scripts seperately).
...unless you mean Java applets/classes, and not Javascript?
I can't help you then...