Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

New line in Javascript

  Asked By: Manju    Date: Apr 22    Category: Asp.net    Views: 1829

I have a tool tip function in javascript, now on mouse over I have a
function called Popup='MYtext .com'

What if I want to have MyText and .com on a different line what new line
command would I use and how in this example?



9 Answers Found

Answer #1    Answered By: Ruairidh Anderson     Answered On: Apr 22

tool tips are generaly done use the Alt or Title attribute of an element and
as such can only contain plain text without any formating.

Answer #2    Answered By: Jay Richards     Answered On: Apr 22

You may try \n to give a line  break in Javascript.
strPopUp = 'Line1';
strPopUp += '\n';
strPopUp += 'Line2';

Answer #3    Answered By: Wade Jordan     Answered On: Apr 22

Well you can actually format a tool  tip using a htc ( if you want the MS
link let me know) But this is a different tool tip  I am building , I just
wanted to know how to create a new line  in javascript.

Answer #4    Answered By: Roderick King     Answered On: Apr 22

I tried that bit it wont work for my string for example:

I have to pass this (following) to my function:

c.Attributes.Add("ONMOUSEOVER", "popup(' Time :" & Time & " Event: " &
Hol & " Venue: " & Venue & " ','LightBlue');")

Now what I am trying to achive is the following result:




That's where the request comes from with the new line.

Is it possible if yes how, I wasn't sure with your previous example  why you
have " ; " after each line  is that needed if yes why and how do I add it to
my example.

Answer #5    Answered By: Fatih Farooq     Answered On: Apr 22

c.Attributes.Add("ONMOUSEOVER", "popup(' Time :" & Time & "\n Event: " &
Hol & "\n Venue: " & Venue & " ','LightBlue');")

Answer #6    Answered By: Isaac Evans     Answered On: Apr 22

That does not work that's what I initially tried when I received all the
posts on\n is for the new line.....?

Any other suggestions, why doesn't the example  below work?

Answer #7    Answered By: Erin Dunn     Answered On: Apr 22

Try using \n\r instead of just \n

It seems to work for me OK.

Answer #8    Answered By: Ana Bradley     Answered On: Apr 22

Try with "\r\n" sequence...............

Answer #9    Answered By: Bernard Gutierrez     Answered On: Apr 22

try with 2 escapes: like


when c# find only one scape char, the compiler think that you whant to
renderize with the new line. but if you scape the '\n' with other '\' ,
it will work.
try yhe same with the \r

Didn't find what you were looking for? Find more on New line in Javascript Or get search suggestion and latest updates.