Return to Kroll Design home page

JavaScript Tutorials

 
« Return

write() method

document.write writes html.
"string" can be a variable or a literal.
Multiple strings to write can be handled by one document.write statement, the strings separated by commas or plus signs.

Code:

<script type="text/javascript">
//<![CDATA[
document.write("This is a literal", "<br><br>");
firstName = "John";
lastName = "Smith";
document.write("This uses commas for concatenation: ", firstName, " ", lastName, "<br>");
document.write("This uses plus signs for concatenation: " + firstName + " " + lastName + "<br>");
//]]>
</script>

Output:



 
« Return


©2012 Kroll Design    info@KrollDesign.net    781.910.3694
Last modified: 12/31/1969 7:00 PM