JavaScript Special Characters
In JavaScript you can add special characters to a text string
by using the
backslash sign.
Insert Special Characters
The backslash (\) is used to insert apostrophes, new lines, quotes, and other
special characters into a text string.
Look at the following JavaScript code:
var txt="We are the so-called "Vikings" from the north.";
document.write(txt);
|
In JavaScript, a string is started and stopped with either single
or double quotes. This means that the string above will be chopped to: We are the so-called
To solve this problem, you must place
a backslash (\) before each double quote in "Viking". This turns each
double quote into a string literal:
var txt="We are the so-called \"Vikings\" from the north.";
document.write(txt);
|
JavaScript will now output the proper text string: We are the so-called "Vikings" from the north.
Here is another example:
document.write ("You \& I are singing!");
|
The example above will produce the following output:
The table below lists other special characters that can be added to a text
string with the backslash sign:
|
Code |
Outputs | |
\' |
single quote | |
\" |
double quote | |
\& |
ampersand | |
\\ |
backslash | |
\n |
new line | |
\r |
carriage return | |
\t |
tab | |
\b |
backspace | |
\f |
form feed |
The Ektron Intranet
lets you do everything you need to do on your corporate intranet and everything you want to do... all with just one application.
What can you do with the Ektron Intranet? |

|
Navigate through content, documents, assets, colleagues and workgroups quickly and intuitively with enterprise search |

|
Communicate with friends and colleagues with forums, message boards and corporate blogging using the new Social Networking Platform |

|
Promote collaboration among coworkers in your organization through project workspaces where others can efficiently find information and work together |

|
Personalize your company profile by bookmarking and organizing favorite content, uploading assets, posting photos, blogging, and more |

|
Interact with features like tagging, flagging, wikis and ratings found in the Web 2.0 Toolbox |
 |
Author/edit content, manage navigation, menus, audit trails, workflow and approvals with the best in breed Content Management |
|
|
|
|
See why there are 20,000+ Ektron integrations worldwide. Request an
INSTANT DEMO or download a
FREE TRIAL today. |
|