It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

auto loading an external js

auto loading an external js

Postby Wag on Sun Feb 17, 2008 8:42 pm

I need to load an external js from an html page.

Could someone help please, I've so many different ways found on the web and none works for me.
Wag
 
Posts: 6
Joined: Sun Feb 17, 2008 8:38 pm

Postby flabbyrabbit on Sun Feb 17, 2008 10:35 pm

I think this is what you are looking for. Save your javascript in a .js file, without the beginning and end <script> tags:
Code: Select all
<script language="JavaScript" src="filename.js"></script>

Flabby Rabbit
Image
User avatar
flabbyrabbit
500+ Club
 
Posts: 706
Joined: Thu Jan 25, 2007 1:10 pm
Location: Midlands, England

external js

Postby Wag on Mon Feb 18, 2008 12:39 am

Yes, that is one of the things I tried and it didn't work.

I'm thinking now that there maybe something wrong with the js file.

http://webpages.charter.net/wag/Javscri ... dar/cal.js
Wag
 
Posts: 6
Joined: Sun Feb 17, 2008 8:38 pm

Postby leonard on Mon Feb 18, 2008 9:19 am

On the page
http://webpages.charter.net/wag/Javscri ... script.htm
the file containing the external script is loaded properly.

The question is:
What do you want to do with the script?

You might want to change your onload function in your body to:
onload="myJSFunction()"

cheers!
- leonard
:%s/^M//
There are 10 kinds of people:
Those who understand binary and those who don't.
User avatar
leonard
100+ Club
 
Posts: 147
Joined: Tue Dec 18, 2007 7:11 am
Location: Switzerland

external js

Postby Wag on Mon Feb 18, 2008 1:22 pm

The js file is supposed to be a calendar.

I added this...
<body onload="myJSFunction()">

Still nothing happens.
Wag
 
Posts: 6
Joined: Sun Feb 17, 2008 8:38 pm

Postby leonard on Mon Feb 18, 2008 3:42 pm

myJSFunction() is just a variable for whatever function you want to call.
Stands for "My JavaScript Function"

cheers!
- leonard
:%s/^M//
There are 10 kinds of people:
Those who understand binary and those who don't.
User avatar
leonard
100+ Club
 
Posts: 147
Joined: Tue Dec 18, 2007 7:11 am
Location: Switzerland

re

Postby Wag on Mon Feb 18, 2008 4:10 pm

Guess your having fun dangling the cheese in front of my face but you did give me enough info to figure it out. It works now, thanks.
Wag
 
Posts: 6
Joined: Sun Feb 17, 2008 8:38 pm

Re: re

Postby leonard on Mon Feb 18, 2008 4:21 pm

Wag wrote:Guess your having fun dangling the cheese in front of my face

Sorry bout that, but I just didn't look at what the functions in your js-file do and which one you want to call.

Have fun with your calender. Seems to be working well now.

cheers!
- leonard
:%s/^M//
There are 10 kinds of people:
Those who understand binary and those who don't.
User avatar
leonard
100+ Club
 
Posts: 147
Joined: Tue Dec 18, 2007 7:11 am
Location: Switzerland


Who is online

Users browsing this forum: No registered users and 1 guest