1.11M Members

how to run javascript program

 
0
 

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?

 
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.

 
0
 

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

 
0
 

and to include js file in your pages

<script language="JavaScript" src="javascript.js" type="text/javascript">
</script>
 
0
 

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

 
0
 

how to run javascript program

 
0
 

How to run a java script program

 
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>
 
0
 

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.

 
0
 

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! :)

 
0
 

*.js files are run with a Javascript interpreter engine. All major browsers have such an engine, as well as most operating systems.

To run the *.js file in a browser, include a reference to the file in a <script> tag. These can be placed within the <head> or <body> tag.

Example:

<html>
    <head>
        <script type="text/javascript" src="path/to/javascript_file.js"></script>
    </head>
</html>

Alternatively, you can also run the *.js file from your operating system given you have a Javascript engine installed on it. One such engine is called "NodeJS". You can use it by calling "node" then the *.js file.

Example:

node javascript_file.js <options>
You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article