document.write

0 Conversations

<!-- this simple script will work if you copy and past it into a browser - the comments will not show because the are enclosed in special tags that hide the text from the browser.

Please note, this is not the case on h2g2 - many tags have been disabled and will cause an error - scripts have also been disabled so if you copy and past this into note pad or other text editor and save it as "document.html", then go to that file via my computer and click on it. it will load it into a browser.

The fact is, this script as very small - what makes it so large is all the comment I have made for instructional purposes.


WHAT ARE TAGS
Tags are commands/instructions etc in html and usually start with a < and ends with a > Many have a starting tag and an ending tag so the browser knows where it starts and where it finishes, but not all.

-->

<!-- This is a Comment inside a tag -->

<!-- = a tag which will hold anything which will not be seen by the browser - these are for remarks or comments to help you remember what you are doing plus hide certain items including SCRIPT from browsers which cannot read javascript.
It ends with a -->

<html>

<!-- The <html> tag must be at the beginning of the code to let the browser known that what follows is html -->

<head>
<!-- The <head> tag is another must - most things in this section are hidden from the browser but not all. Hidden commands and instructions can be held here as well as instructions for search engines. -->

<title>
<!-- The <title> tag houses the pages name which shows at the top of the browser, above the File - Edit and View drop down menus. In this case it is called "document.write sample 1" but it can be called anything you like. Its kinda like your personal heading to the page.
-->

document.write sample 1

</title>
<!-- the </title> tag tells the browser that it is the end of the title area - note the forward slash. You will come across this in other tags to show that an instruction/tag has come to an end. -->

</head>
<!-- to denote the <head> area has come to an end - note that forward slash again. -->

<body>
<!-- The <body> tag tells the browser this is where the beginning of the page will be - from now on all will be seen on the screen. -->

<script>
/* The Script tag denotes to the browser to start the hidden javascript programing - some browsers require more information but we will go into that later. */

document.write("This text will appear on the screen")

// our first piece of java script

/* - document is an object - I explain the syntax later. write is known as a method - the method, document it utilised.
*/
</script>

<!-- close of the <script> language with the </script> tag with the forward slash again -->

<!-- Note that inside the script area the comments tag has been replaced with /* and */ - or a single line comment has // at the beginning of the line - these comment will be ignored by javascript and the browser. -->

</body>
<!-- closing of the body area with the </body> tag - note the forward slash again

</html>
<!-- Closing of the page and html ends here with the </html> tag - again the forward slash to denote the end -->


Back to javascript page 2 http://www.bbc.co.uk/h2g2/guide/A623747

Bookmark on your Personal Space


Conversations About This Entry

There are no Conversations for this Entry

Entry

A624502

Infinite Improbability Drive

Infinite Improbability Drive

Read a random Edited Entry


Written and Edited by

Disclaimer

h2g2 is created by h2g2's users, who are members of the public. The views expressed are theirs and unless specifically stated are not those of the Not Panicking Ltd. Unlike Edited Entries, Entries have not been checked by an Editor. If you consider any Entry to be in breach of the site's House Rules, please register a complaint. For any other comments, please visit the Feedback page.

Write an Entry

"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."

Write an entry
Read more