• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

external javascript file

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic