Pages

Javascript String - link() Method

4/7/14

Description:

This method creates an HTML hypertext link that requests another URL.

Syntax:

string.link( hrefname )
Here is the detail of parameters:
  • hrefname: Any string that specifies the HREF of the A tag; it should be a valid URL.

Return Value:

  • Returns the string with <a> tag.

Example:

<html>
<head>
<title>JavaScript String link() Method</title>
</head>
<body>
<script type="text/javascript">

var str = new String("Hello world");
var URL = "http://www.tutorialspoint.com";

alert(str.link( URL ));

</script>
</body>
</html>
This will produce following result:
<a href="http://www.tutorialspoint.com">Hello world</a>
Read more ...

Javascript String - italics() Method

4/7/14

Description:

This method causes a string to be italic, as if it were in an <i> tag

Syntax:

string.italics( )
Here is the detail of parameters:
  • NA

Return Value:

  • Returns the string with <i> tag.

Example:

<html>
<head>
<title>JavaScript String italics() Method</title>
</head>
<body>
<script type="text/javascript">

var str = new String("Hello world");

alert(str.italics( 3 ));

</script>
</body>
</html>
This will produce following result:
<i>Hello world</i>
Read more ...

Javascript String - fontsize() Method

4/7/14

Description:

This method causes a string to be displayed in the specified size as if it were in a <font size="size"> tag.

Syntax:

string.fontsize( size )
Here is the detail of parameters:
  • color: An integer between 1 and 7, a string representing a signed integer between 1 and 7.

Return Value:

  • Returns the string with <font size="size"> tag.

Example:

<html>
<head>
<title>JavaScript String fontsize() Method</title>
</head>
<body>
<script type="text/javascript">

var str = new String("Hello world");

alert(str.fontsize( 3 ));

</script>
</body>
</html>
This will produce following result:
<font size="3">Hello world</font>
Read more ...

Javascript String - fontcolor() Method

4/7/14

Description:

This method causes a string to be displayed in the specified color as if it were in a <font color="color"> tag.

Syntax:

string.fontcolor( color )
Here is the detail of parameters:
  • color: A string expressing the color as a hexadecimal RGB triplet or as a string literal.

Return Value:

  • Returns the string with <font color="color"> tag.

Example:

<html>
<head>
<title>JavaScript String fontcolor() Method</title>
</head>
<body>
<script type="text/javascript">

var str = new String("Hello world");

alert(str.fontcolor( "red" ));

</script>
</body>
</html>
This will produce following result:
<font color="red">Hello world</font>
Read more ...

Javascript String - fixed() Method

4/7/14

Description:

This method causes a string to be displayed in fixed-pitch font as if it were in a <tt> tag.

Syntax:

string.fixed( )
Here is the detail of parameters:
  • NA:

Return Value:

  • Returns the string with <tt> tag.

Example:

<html>
<head>
<title>JavaScript String fixed() Method</title>
</head>
<body>
<script type="text/javascript">

var str = new String("Hello world");

alert(str.fixed());

</script>
</body>
</html>
This will produce following result:
<tt>Hello world</tt>
Read more ...

Javascript String - bold() Method

4/7/14

Description:

This method causes a string to be displayed as bold as if it were in a <b> tag.

Syntax:

string.bold( )
Here is the detail of parameters:
  • NA:

Return Value:

  • Returns the string with <bold> tag.

Example:

<html>
<head>
<title>JavaScript String bold() Method</title>
</head>
<body>
<script type="text/javascript">

var str = new String("Hello world");

alert(str.bold());

</script>
</body>
</html>
This will produce following result:
<b>Hello world</b>
Read more ...

Javascript String - blink() Method

4/7/14

Description:

This method causes a string to blink as if it were in a BLINK tag.

Syntax:

string.blink( )
Here is the detail of parameters:
  • NA:

Return Value:

  • Returns the string with <blink> tag.

Example:

<html>
<head>
<title>JavaScript String blink() Method</title>
</head>
<body>
<script type="text/javascript">

var str = new String("Hello world");

alert(str.blink());

</script>
</body>
</html>
This will produce following result:
<blink>Hello world</blink>
Read more ...

Javascript String - big() Method

4/7/14

Description:

This method causes a string to be displayed in a big font as if it were in a BIG tag

Syntax:

string.big( )
Here is the detail of parameters:
  • NA:

Return Value:

  • Returns the string having <big> tag.

Example:

<html>
<head>
<title>JavaScript String big() Method</title>
</head>
<body>
<script type="text/javascript">

var str = new String("Hello world");

alert(str.big());

</script>
</body>
</html>
This will produce following result:
<big>Hello world</big>
Read more ...

Javascript String - anchor() Method

4/7/14

Description:

This method creates an HTML anchor that is used as a hypertext target.

Syntax:

string.anchor( anchorname )
Here is the detail of parameters:
  • anchorname: Defines a name for the anchor.

Return Value:

  • Returns the string having anchor tag.

Example:

<html>
<head>
<title>JavaScript String anchor() Method</title>
</head>
<body>
<script type="text/javascript">

var str = new String("Hello world");

alert(str.anchor( "myanchor" ));

</script>
</body>
</html>
This will produce following result:
<a name="myanchor">Hello world</a>
Read more ...

Javascript String - valueOf() Method

4/6/14

Description:

This method returns the primitive value of a String object.

Syntax:

string.valueOf( )
Here is the detail of parameters:
  • NA

Return Value:

  • Returns the primitive value of a String object.

Example:

<html>
<head>
<title>JavaScript String valueOf() Method</title>
</head>
<body>
<script type="text/javascript">

var str = new String("Hello world");

document.write(str.valueOf( ));
</script>
</body>
</html>
This will produce following result:
Hello world
Read more ...

Related Posts