1

I am working on a notification's bar that displays all friend requests a user received as well as note's posted to him etc. So my notification's bar displays a sum of these recent event's and on a mouse over that notification's bar displays the details like friend requests,message's received,comments posted etc separated by a new line.

echo "<a href='notifications.php?id=all_notifications' class='notification_text'   title='".$title."'>"."You have ".$notifications->notification_counter." new notifications!</a> <a class='close_button' href='#' onclick='ajaxcaller_one_param(\"clear_notifications_bar\");return false;'></a>";

The problem is the $title which has all the messages concatenated in it over various if blocks and has \n at the end of each string.

mozilla ignores the \n at the end and places all the messages side by side without a space. how can i eliminate this issue???

Sanjay Rao
  • 547
  • 1
  • 11
  • 22
  • possible duplicate of [How can I use a carriage return in a HTML tooltip?](http://stackoverflow.com/questions/358874/how-can-i-use-a-carriage-return-in-a-html-tooltip) – Mike Aug 24 '11 at 05:12
  • possible duplicate of http://stackoverflow.com/questions/246438/newline-in-td-title – Flask Aug 24 '11 at 10:04

2 Answers2

4

If that is displayed as HTML, replace \n with <br />

rockerest
  • 10,412
  • 3
  • 37
  • 67
Eddy Chan
  • 1,161
  • 1
  • 8
  • 15
  • 2
    Also, SANJAY appears to be using PHP where he can use the native function `nl2br()` to transform the text – Anshul Aug 24 '11 at 05:12
2

The way the title attribute is rendered depends upon/varies with browser. According to this article, Firefox displays the tooltip correctly, ignoring LF and replacing CR with space. I suggest that you use a JavaScript tooltip plugin instead.

Salman A
  • 262,204
  • 82
  • 430
  • 521