Writing / Inserting html tags
Writing/Inserting a html code using javascript?
How to break the sequence of write method?
Explanation
HTML Code:
HTML tags or code can also be added using document.write method.
i.e. Just use the html code as the argument for document.write or document.writeln functions
document.write("--
bold red --");
Example:
<script language=javascript>
document.write("-- <b>bold</b> <font color=red> red </font>--");
</script>
Result:
Break line for .write method :
document.write will append the string to the previous string.
i.e. if you call
document.write(" -- first line ---");
document.write(" -- second line ---");
the result will be as " -- first line --- -- second line ---";
So in order to break the lines in the browser you have to use an additional code "<br>" at the end.
e.g: document.write(" -- first line --- <br>");
Example:
<script language=javascript>
document.write(" -- first line --- <br>");
document.write(" -- second line --- <br>");
</script>
Result: