Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

JavaScript QuickStart: What Is JavaScript? : Page 4

JavaScript. It has all the hallmarks of "flavor of the month"—its name is appearing everywhere and there's panting and foaming at the mouth over learning to use it. So what is it? And why should you care?


advertisement

Look at a Script
So how complicated are JavaScript scripts? And how do you recognize one in an HTML text page?

Scripts can range from the very basic to the very complex, depending on what they do and how they were written. It's easy to spot a JavaScript script in an HTML source file. Just look for the tags:

<script language="javascript"> and </script>.



The script appears between them. Most often, the script will be at the very beginning of the HTML text file.

In most cases, it is good style to place the scripts first. In other cases, it is essential that the script is first. For example, if you are using a script to see what type of browser the reader is using and to deliver the appropriate page for that browser type, the detection script must be the first thing in the file or the script won't work correctly.

This is an example of a script. Click on it to see how it acts. The example appears in the window at the top of the screen:

<script language="javascript">

    document.writeln("This line of text<br>");
    document.writeln("Is generated by a script");

</script>

This is a very simple script:

  • The first line tells the document to write a line of text. The text to write is the words "This line of text" followed by the HTML break tag.

  • The second line tells the document to write a second line of text. The text is "Is generated by a script."

    That's all the script does. It can be as simple as that.





Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap