929Chapter 34 .The String Object yourName = prompt( Please (Web hosting bandwidth)
Tuesday, March 4th, 2008929Chapter 34 .The String Object yourName = prompt( Please enter your name: , ) var msg = Good afternoon, + yourName + . alert(msg) Some common problems that you may encounter while attempting this kind of concatenation include the following: . Accidentally omitting one of the quotes around a literal string . Failing to insert blank spaces in the string literals to accommodate word spaces . Forgetting to concatenate punctuation after a variable value Also, don t forget that what I show here as variable values can be any expression that evaluates to a string, including property references and the results of some methods. For example var msg = The name of this document is + document.title + . alert(msg) Special inline characters The way string literals are created in JavaScript makes adding certain characters to strings difficult. I m talking primarily about adding quotes, carriage returns, apostrophes, and tab characters to strings. Fortunately, JavaScript provides a mechanism for entering such characters into string literals. A backslash symbol, followed by the character that you want to appear as inline, makes that task happen. For the invisible characters, a special set of letters following the backslash tells JavaScript what to do. The most common backslash pairs are as follows: . Double quote . Single quote (apostrophe) . \ Backslash . b Backspace . t Tab . n New line . r Carriage return . f Form feed Use these inline characters (also known as escaped characters, but this terminology has a different connotation for Internet strings) inside quoted string literals to make JavaScript recognize them. When assembling a block of text that needs a new paragraph, insert the n character pair. Here are some examples of syntax using these special characters:
Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.