954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to run javascript program

I have saved a javascript in notepad with an .htm extension. When I go to file then open and type in the file name, it just opens up a it as an address in the address bar. I want to run the program in internet explorer, how do I do that?

idesignyards
Newbie Poster
1 post since Oct 2006
Reputation Points: 10
Solved Threads: 0
 

If the file is just a javascript file you have to save it with a .js file extension and then call it from an HTML page as JavaScript does not run on its own. It must be part of a webpage.

stymiee
He's No Good To Me Dead
Moderator
3,360 posts since May 2006
Reputation Points: 161
Solved Threads: 38
 

another think to keep in mind, if you take that script from somebody site it may not work properly/ at all because it need some data

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

and to include js file in your pages

<script language="JavaScript" src="javascript.js" type="text/javascript">
</script>
vishesh
Nearly a Posting Virtuoso
1,381 posts since Oct 2006
Reputation Points: 85
Solved Threads: 42
 

It seems that I can run the .js file from Windows. Just double click it.

chiwawa10
Junior Poster
156 posts since Jul 2005
Reputation Points: 88
Solved Threads: 27
 

how to run javascript program

nitin.kachale
Newbie Poster
1 post since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

How to run a java script program

infotech_mominp
Newbie Poster
1 post since May 2010
Reputation Points: 10
Solved Threads: 0
 

You can run the javascript by including within your html file or just include the External Javascript file within the html file.

<html>
<head>
<!-- Internal Javascript Function -->
<script language="javaScript">
//Write your javascript functions within this script tag
</script>
<!-- External Javascript Function -->
<script language="JavaScript" src="javascript.js" type="text/javascript"/>
</head>
<body>
</body>
</html>
rajarajan07
Nearly a Posting Virtuoso
1,447 posts since May 2008
Reputation Points: 167
Solved Threads: 239
 

is it possible to placing 3 div horizontally, and want to make it display & hide div on click. but rest of the div will be in full width as the page.

Rajib Ganguly
Newbie Poster
14 posts since Jun 2010
Reputation Points: 10
Solved Threads: 5
 

Using <script language="JavaScript" src="javascript.js" type="text/javascript"/> is not valid (as per the W3C) for 2 reasons. The first being that the script tag is a content element and must use a </script> to close the elements envelope. The second, if the script tag was a leaf (contentless) element, there must contain a space before the /> . Using language="JavaScript" has been deprecated.

The only exception to this is when using XHTML, and although using the script tag as a leaf element will parse correctly in most modern browsers, it will cause the page to break in older browsers. This lack of backward compatibility is the primary reason the W3C will ONLY validate the script tag as a leaf element when used in XHTML.

To prove this point, I have provided a srcipt tag test using standard HTML and a srcipt tag test using XHTML. The official W3C validator can be found at validator.w3.org site.

Lastly, your in page script must use type="text/javascript" to validate correctly. Again, using language="JavaScript" has been deprecated and is not necessary.

Hope this helps. Enjoy! :)

oakleymk
Newbie Poster
14 posts since Jun 2009
Reputation Points: 10
Solved Threads: 2
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You