|
|
JavaScript Introduction - Writing JavaScript with HTMLTake a look at the following code:
<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
<!--
document.write("JavaScript is <B>great</B>.");
//-->
</SCRIPT>
You'll notice that along with the text I've thrown in the HTML bold tag. HTML tags enclosed in write() are not displayed. The browser interprets these tags accordingly and then prints the result. In our case, the word 'great' is displayed in bold. Here is a code that prints text in blue color:
<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
<!--
document.write('<FONT COLOR="#0000FF">Blue denim</FONT>');
//-->
</SCRIPT>
Click here to view the result. Note that I have used single quotes to enclode the text in write(). Why? Because it is my habit to contain HTML attribute values with double quotes. If I had used double quotes to surround both the attribute value and the text in write(), I would have received an error from the JavaScript interpreter. JavaScript allows inclusion of all HTML tags in write(). You can actually build entire HTML documentes starting from <HTML> tag!
Page contents: Writing javascript with html - introduction to javascript - javascript on web pages
Page URL: http://www.webdevelopersnotes.com/tutorials/javascript/ javascript_introduction_writing_javascript_web_page_html.php3
|
|