You can use HTML tag methods to place HTML elements around text in a String object.
Syntax ExamplesThe following examples show how to use the HTML tag methods.
var strVariable = "This is an anchor.";
document.write(strVariable.anchor("Anchor1"));
var strVariable = "This is a string.";
document.write(strVariable.big());
var strVariable = "This is a string.";
document.write(strVariable.blink());
var strVariable = "This is a string.";
document.write(strVariable.bold());
var strVariable = "This is a string.";
document.write(strVariable.fixed());
var strVariable = "This is a string.";
document.write(strVariable.fontcolor("red"));
var strVariable = "This is a string.";
document.write(strVariable.fontsize(-1));
var strVariable = "This is a string.";
document.write(strVariable.italics());
var strVariable = "This is a hyperlink.";
document.write(strVariable.link("http://www.microsoft.com"));
var strVariable = "This is a string.";
document.write(strVariable.small());
var strVariable = "This is a string.";
document.write(strVariable.strike());
var strVariable = "This is a string.";
document.write(strVariable.sub());
var strVariable = "This is a string.";
document.write(strVariable.sup());
Remarks
No checking is performed to determine whether the HTML tags have already been applied to the string.
SyntaxThe following table lists the syntax for and a description of each HTML tag method.
In the Syntax column, string1 is a String object or literal.
The Standard column indicates World Wide Web Consortium (W3C) recommendations for HTML 4. “Discouraged” indicates that the HTML element is discouraged in favor of style sheets.
Syntax Method description Parameter description Standard string1.anchor( name ) Places an HTML anchor that has a NAME attribute around the text. The name parameter is text to put in the NAME attribute of the HTML anchor. string1.big() Places HTML \ tags around the text. Discouraged string1.blink() Places HTML \ tags around the text. The \ tag is not supported in Internet Explorer. Not in standard string1.bold() Places HTML \ tags around the text. Discouraged string1.fixed() Places HTML \ tags around the text. Discouraged string1.fontcolor( color ) Places HTML \ tags with a COLOR attribute around the text. The color parameter is a string value that contains the hexadecimal value or predefined name for a color. Valid predefined color names depend on the JavaScript host browser and its version. Deprecated string1.fontsize( size ) Places HTML \ tags with a SIZE attribute around the text. The size parameter is an integer value that specifies the size of the text. Valid integer values depend on the JavaScript host browser and its version. Deprecated string1.italics() Places HTML \ tags around the text. Discouraged string1.link( href ) Places an HTML anchor that has an HREF attribute around the text. The href parameter is text to put in the HREF attribute of the HTML anchor. string1.small() Places HTML \ tags around the text. Discouraged string1.strike() Places HTML \ tags around the text. Deprecated string1.sub() Places HTML \ tags around the text. string1.sup() Places HTML \ tags around the text.## See also
Other articles AttributionsMicrosoft Developer Network: Article
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4