wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes external javascript file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "external javascript file" Watch "external javascript file" New topic
Author

external javascript file

swapnil paranjape
Ranch Hand

Joined: May 15, 2005
Posts: 126
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
Marshal

Joined: Mar 22, 2005
Posts: 41052
    
  43
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.


Ping & DNS - my free Android networking tools app
swapnil paranjape
Ranch Hand

Joined: May 15, 2005
Posts: 126
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

Joined: Dec 13, 2004
Posts: 429
..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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: external javascript file
 
Similar Threads
How to calculate the time difference in javascript?
Date not getting displayed
Exception in thread "main" java.lang.NoClassDefFoundErro
Appending the data in frame or popup window
Radio button