Unix/Linux Go Back    


Web Programming Discuss Web Programming and Web Server Administration, including LAMP, Apache, MySQL, HTML, SEO, and other Web APIs and topics.

Path to javascript source code at local browsing

Web Programming


Tags
javascript, path, source

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 06-27-2017
yifangt yifangt is offline VIP Member  
UNIX.COM VIP Member
 
Join Date: Sep 2009
Last Activity: 20 October 2017, 5:04 PM EDT
Location: Saskatchewan, Canada
Posts: 512
Thanks: 326
Thanked 7 Times in 7 Posts
Path to javascript source code at local browsing

Where should I put my javascript source code in order to run it "locally" by file not by http?---not sure this "locally" is the appropriate word here.
My test is when my javascript code (test.js) is put in the site default folder as the test.html in /var/www/html both worked as expected with http:

Code:
http://localhost/test.html


Code:
<script type="text/javascript" src="/test.js"> </script>

However, when I tried to test it at URL window with file:

Code:
file:///home/davids/study/WebTech/test.html

I can see my html result, but my javascript code was not executed.
Where should I put the external javascript source code (here:test.js) in order to test it "locally"?

Thanks!
Sponsored Links
    #2  
Old Unix and Linux 06-27-2017
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 20 October 2017, 2:22 PM EDT
Location: Aachen, Germany
Posts: 11,479
Thanks: 310
Thanked 3,561 Times in 3,276 Posts
You need to supply the correct (relative or absolute) path to test.js. As given, the html script will look into the root directory (unless chrooted).
The Following User Says Thank You to RudiC For This Useful Post:
yifangt (06-27-2017)
Sponsored Links
    #3  
Old Unix and Linux 06-27-2017
yifangt yifangt is offline VIP Member  
UNIX.COM VIP Member
 
Join Date: Sep 2009
Last Activity: 20 October 2017, 5:04 PM EDT
Location: Saskatchewan, Canada
Posts: 512
Thanks: 326
Thanked 7 Times in 7 Posts
Thanks!
Ahh, back slash "/" - that is the root!


Last edited by yifangt; 06-27-2017 at 05:13 PM..
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Migrate /export/home from storage path to local Deeo Solaris 6 12-21-2016 06:59 AM
Generate class path dynamically based on source path oraclermanpt Shell Programming and Scripting 0 12-19-2016 03:27 PM
Source path Oggie25 UNIX for Dummies Questions & Answers 8 11-30-2012 04:39 AM
Save page source, including javascript locoroco Shell Programming and Scripting 1 09-11-2011 12:34 PM



All times are GMT -4. The time now is 04:15 AM.