Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

external javascript file

 
swapnil paranjape
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing problem while using external javascript file.
My html page contains following code in the body section

script src="localpath\abc.js"
var start = starttimestamp();
alert("hi")
var endtime = endtimestamp();
timestamp(start,endtime)

now my js file abc.js contains 3 functions starttimestamp,endtimestamp,timestamp (it doesnt contain script tag)

but when i try to load html page nothing happens...actually function shud execute and write the result.

why this is happening?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the JS file actually being found? Try putting an alert(...) at the beginning of the file and see if it pops up. Maybe something subtle is wrong with the path or file name.
 
swapnil paranjape
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think the js file is not found because the after body tag nothing from the script tag in html is getting executed.....i have this js file and html file in same folder....i am providing the whole path to js file eg. c:\newfolder\abc.js

what cud be wrong?
in the script tag i am using proper comment also.
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
..i have this js file and html file in same folder....i am providing the whole path to js file eg. c:\newfolder\abc.js

I'm not completely sure about html syntax for absolute paths, but if the html and js are in the same folder, why not just do src="abc.js" in the script element?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic