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

Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 06-27-2017   -   Original Discussion by yifangt
yifangt's Unix or Linux Image
yifangt yifangt is offline VIP Member  
UNIX.COM VIP Member
 
Join Date: Sep 2009
Last Activity: 22 January 2018, 3:47 PM EST
Location: Saskatchewan, Canada
Posts: 516
Thanks: 334
Thanked 8 Times in 8 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   -   Original Discussion by yifangt
RudiC's Unix or Linux Image
RudiC RudiC is online now Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 23 January 2018, 8:59 AM EST
Location: Aachen, Germany
Posts: 11,980
Thanks: 356
Thanked 3,692 Times in 3,390 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   -   Original Discussion by yifangt
yifangt's Unix or Linux Image
yifangt yifangt is offline VIP Member  
UNIX.COM VIP Member
 
Join Date: Sep 2009
Last Activity: 22 January 2018, 3:47 PM EST
Location: Saskatchewan, Canada
Posts: 516
Thanks: 334
Thanked 8 Times in 8 Posts
Thanks!
Ahh, back slash "/" - that is the root!


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

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 07:59 AM
Generate class path dynamically based on source path oraclermanpt Shell Programming and Scripting 0 12-19-2016 04:27 PM
Source path Oggie25 UNIX for Dummies Questions & Answers 8 11-30-2012 05:39 AM
Save page source, including javascript locoroco Shell Programming and Scripting 1 09-11-2011 01:34 PM



All times are GMT -4. The time now is 10:00 AM.