PRINT to Browser with document.write Command in Javascript
Inside your Javascript tags type:
document.write('I see Paris');
Which prints:
I see Paris
Simple enough. Now let's add a variable.
var huhu="London";
document.write('I see Paris but ' + huhu + ' is out of site.');
Which prints:
I see Paris but London is out of site.
Plus symbols + allow you to connect the variable huhu to the rest of the sentence.
You could have also done it like this:
var huhu="London";
document.write('I see Paris but ');
document.write(huhu);
document.write(' is out of site.');
Same results with more typing.
Copy and Paste Javascript Code:
<script type=text/javascript>
<!--
var huhu="Nikki";
document.write('I see Paris but ' + huhu + ' is out of site.<br>');
document.write('I see Paris but ');
document.write(huhu);
document.write(' is out of site.');
-->
</script>
Javascript document.write - See in Action (new window)
Click HERE to comment or discuss at iLoveTheCode GOOGLE Group
| | | |
| | CSS David McFarland | |
| | | |