There isn't too much required to write using JavaScript. You just need to have basic Internet, computer and word processing skills---a little hypertext markup language (HTML) knowledge would help, too. It is the computer language (or code) that Internet browsers and computers use to talk to each other. JavaScript uses the same principles as HTML. It just adds a few more bits of language vocabulary.
Instructions
- 1
Format your work properly. Create a new file in Notepad and save it to your desktop with an html extension. This will generate a web page icon. Right-click on this icon, click the phrase "Open With" and then click Notepad. Your document is now ready to write using JavaScript.
2Determine where you want your script to go. A major difference between HTML and JavaScript is the phrases you use. JavaScript builds on HTML language and where you place your phrases are important. Write using JavaScript with this main tag: "." You're going to place these two tags inside another tag called a "header." The header goes just under the main html tag (). A good example string will look like this: "
Use the document dot write phrase (document.write), parentheses and quotes then place one semicolon at the end of every code line. Semicolons are just a way for a computer to recognize a break in information, just like a period at the end of a sentence. JavaScript is the only language that uses this syntax so don't wrap angle brackets around the document write phrase. The semicolon generates the break you need already. A sample will look like this: "document.write ("Place the text you want to appear on a page here.");". Take your script tags (listed above) and marry them with the document write phrase like this: "". You can place this script inside either your header or body, depending on what you want to have happen.
4Use headers one through six. Header and headers one through six all work completely differently. The header tag looks like this "." You can make headers throughout your page by writing JavaScript using the header numbers in ascending order like this "
". Know that the larger the numbers, the smaller your header will appear on a page. Make sure to marry a closed tag with each. Place these tags inside your document.write statement inside the quotes. An example will look like this: "document.write("
Place the text you want to appear on the page here.
");".