• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 646
  • Last Modified:

Help needed for relative path to external js file

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
iLvChopin
Asked:
iLvChopin
1 Solution
 
ZvonkoSystems architectCommented:
Your example is correct. You have anywere else a typo.
0
 
ZvonkoSystems architectCommented:
I just simulated your example on my server and it worked!
You have a typo.
0
 
iLvChopinAuthor Commented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
dakydCommented:
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
 
iLvChopinAuthor Commented:
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
 
ZvonkoSystems architectCommented:
Typo ;-)
0
 
ThogekCommented:
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

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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now