Solved

Help needed for relative path to external js file

Posted on 2004-08-04
9
635 Views
Last Modified: 2008-03-17
This sounds pretty simple however it didn't work for me. I have an external js file myjscript.js in /home/js. I have a mypage.htm in /home/myfile/dir1
In the mypage.htm body I need to include the external js file. I used

<script language="javascript" src="../../js/myjscript.js"></script>

When I opened the htm page in browser, it couldn't locate the js file. What's wrong here? I don't want to use absolute path. Can anyone shed some light on this?? Thank you!
0
Comment
Question by:iLvChopin
9 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 11718219
Your example is correct. You have anywere else a typo.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11718340
I just simulated your example on my server and it worked!
You have a typo.
0
 

Author Comment

by:iLvChopin
ID: 11719238
I double checked and there is no typo. Again this js file was included in the body of the htm page not in between the header tag. I think the relative path is correct but the page can't find the js file.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 19

Expert Comment

by:dakyd
ID: 11719322
Zvonko's right ... the example you posted should work fine.  Try a quick test - add this as the very first line of your external js:
alert("found the external js");

If you see the alert, the file is linked properly.  If not, there's a different problem with your page.  Hope that helps.
0
 

Accepted Solution

by:
iLvChopin earned 0 total points
ID: 11719812
OK I figured out what's wrong. It is the double quotes and single quotes messed up issue cause it is within other script sentence. Thanks.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11719920
Typo ;-)
0
 
LVL 15

Expert Comment

by:Thogek
ID: 11721408
Note that it's sometimes easier (and clearer) to just use the local absolute path of the script file, such as:

    <script language="javascript" src="/home/js/myjscript.js"></script>
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Serialize On-Key-Up Functions 3 28
Add code to body in wordpress site 8 36
Where to begin studying? 5 64
Adjust the position 3 0
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now