This is the second JavaScript tutorial here i am using JavaScript to create text on the webpage.
It is simple and doesn't require a lot of scripting.
<body> This is the body of the script
<p>Some Text<br/> This is the body text
<script type="text/javascript"> This is the script type which is JavaScript this time its in the body
var line = "this is a line"; Here Here we are creating a variable a variable is used to hold values or expressions so var line is equal to the text "this is a line"
var line2 = "and this is another..."; This is another variable but this one is called line2
document.writeln(line); This says write a line of text in the document and in brackets the variable which is line
document.writeln("<br/>"); This breaks the line so it doesn't go right next to the last text
document.writeln(line2); This writes in the 2nd variable which is line2
</script> This ends the script tag
<br/>and some more text</p> This is a paragraph text in the body
</body> This ends the body
This is a simple way of putting text in a document through JavaScript and the text loads a lot quicker than HTML. I think its an easier to create text like this as well because if you have the same word somewhere in your website you can just use a variable to create the text.
No comments:
Post a Comment