LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-25-2011, 08:59 AM   #1
secretlydead
Member
 
Registered: Sep 2003
Location: Qingdao, China
Distribution: mandriva, slack, red flag
Posts: 249

Rep: Reputation: 31
javascript line break


i have some variables that are loaded from mysql - in mysql, the line breaks are not indicated by '\n' or '<br>' or anything -they are just line breaks.

the variable is loaded into javascript and then inserted into a <pre> element. the line breaks are not showing up.

pre1 = pre1.replace(/>/g,"&gt;"); - this works well, naturally. but how do i get those line breaks to show up as line breaks in a browser?

i've tried many variations of something like
pre1 = pre1.replace(/\\n/g,"<br>");
 
Old 02-25-2011, 09:12 AM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
How about using < and > for < and >, respectively?

(These are ascii character codes by the way.)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
line break on bash script ZAMO Linux - General 5 04-24-2010 12:27 PM
break line into words nushki Programming 16 12-04-2009 09:15 AM
!? element names beginning with number break javascript??? UMG:Chicken_Soüp Programming 1 01-27-2008 11:12 PM
CVS's line break management zWaR Programming 1 04-16-2007 09:00 PM
line break tag in mozilla firebird mbegovic Linux - Software 0 04-28-2004 07:20 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration