How to put a separate Javascript file in my html page?

  • Thread starter Thread starter Mark R
  • Start date Start date
M

Mark R

Guest
I need to put a Javascript file ( www.jokes2text.com/jokes.js ) into another HTML page, both on the same site, and on another site. I have tried using

<script type="text/javascript" src="jokes.js"></script>

but it doesnt work at all. I tried running the Javascript code in an editor and it seems to work fine there. I just need the output

GetStatement(0)

to show up as text.
I still cant get it to run. Im not sure how to call it or make it automatically run on a page. Im new(er) to programming and Java.

Whats the most basic code I can use to get it to run on a new blank webpage, and I can figure it out from there.
 
There's no problem with the code you are using to include your JavaScript.

Try changing your src value to be absolute (E.g. www.jokes2text.com/jokes.js).

Where abouts on the page is the JavaScript output supposed to be displayed? Perhaps it has the wrong name or something silly like that.

What triggers the JavaScript to run? Are you using onload in the body tag? Or do you just have the javascript running as it loads? Put your javascript into a function and then have the function run when the page loads (using the onload attribute of the body tag.)
 
Back
Top