Solved

Help needed for relative path to external js file

Posted on 2004-08-04
9
641 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jQuery on click requires double click 6 34
Link not working 6 43
disable and enable textboxes in dataTable 7 30
Diff of the day 2 9
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

726 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