Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

External .js files

Status
Not open for further replies.

RedRobotHero

Technical User
May 2, 2003
94
CN
I'm having trouble including an external .js file. When I put the javascript directly into the html, it works. But when I use
Code:
<script type=&quot;text/javascript&quot; language=&quot;JavaScript&quot; src=&quot;/menua.js&quot;></script>
to include it, it doesn't work.

(it works in this one)


(it doesn't work in this one)


I'm using the same method to include two javascript files, but the one included with
Code:
<script type=&quot;text/javascript&quot; language=&quot;JavaScript&quot; src=&quot;/menub.js&quot;></script>
does execute. The only difference between the two is that menub is included further down than menua.
 
Oh, the javascript is for the folding menu on the right.
 
<script type=&quot;text/javascript&quot; language=&quot;JavaScript&quot; src=&quot;/menub.js&quot;></script>

what is that slash doing there?

Known is handfull, Unknown is worldfull
 
Code:
<script type=&quot;text/javascript&quot; language=&quot;JavaScript&quot; src=&quot;
/
Code:
menub.js&quot;></script>

That slash?

Well, that page is actually something made from a cgi script, here.

But I'm still mucking about with the templates for that script, so I made two copies of the output for examples. I put them in the base directory instead of the cgi directory, but the links for the images still work, so I didn't think that would be a problem.
 
Don't put anything in your CGI-BIN directory except for CGI scripts. To use external javascript files, put this between your <head></head> tags:

<SCRIPT SRC=&quot;yourexternalfile.js&quot; TYPE=&quot;text/javascript&quot;></SCRIPT>

You don't need 'language=&quot;JavaScript&quot; - it's implied.

There's always a better way. The fun is trying to find it!
 
try removing the slash, i couldnt get ur previois post, where is the js file and html file located? in the same directory?

Known is handfull, Unknown is worldfull
 
Is it impossible to include javascript that is inside the
Code:
<body>
section? I didn't think they had to be in the
Code:
<head>
section, because the &quot;/menub.js&quot; reference works, and it is inside the
Code:
<body>
section.
 
Okay. I tried a version with it in the
Code:
<head>
section, and it doesn't work either.



I am referencing three external javascript files in this page.
Code:
rolls.js menua.js menub.js

Code:
menua.js
is the only one that doesn't work. Why?
 
Okay. I'm dumb. I hadn't uploaded the new version of menua.js
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top