Solved

Help needed for relative path to external js file

Posted on 2004-08-04
9
642 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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