HTML and CSS Reference
In-Depth Information
Table 9.9 String Object (HTML) Methods (continued)
Method
Formats as HTML
String.bold()
<b>String</b>
String.fixed()
<tt>String</tt>
String.fontcolor(color)
<font color="color">String</font>
e.g., <font color="blue">String</font>
String.fontsize(size)
<font size="size">String</font>
e.g., <font size="+2">String</font>
String.italics()
<i>String</i>
String.link(URL)
<a href="URL">String</a>
e.g., <a href="http://www.ellieq.com">String</a>
String.small()
<small>String</small>
String.strike()
<strike>String</strike> (puts a line through the text)
String.sub()
<sub>String</sub> (creates a subscript)
String.sup()
<sup>String</sup> (creates a superscript)
EXAMPLE 9.26
<html>
<head><title>String object</title></head>
<body bgcolor="yellow">
<big>
<font face="arial">
<h2>Working with String Objects:</h2>
<script type="text/javascript">
1
var str1 = new String("Hello world!");
// Use a String constructor
2
var str2 = "It's a beautiful day today.";
document.write(str1) + "<br />";
3
document.write( str1.fontcolor("blue" )+"<br />");
4
document.write( str1.fontsize(8).fontcolor("red").bold() +
"<br />");
5
document.write( str1.big() + "<br />");
6
document.write(" Good-bye, ".italics().bold().big() +
str2 + "<br />");
</script>
</font>
</big>
</body>
</html>
 
Search WWH ::




Custom Search