<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Line endings in Javascript</title>
	<atom:link href="http://www.sitepoint.com/blogs/2004/02/16/line-endings-in-javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sitepoint.com/blogs/2004/02/16/line-endings-in-javascript/</link>
	<description>News, opinion, and fresh thinking for web developers and designers. The official podcast of sitepoint.com.</description>
	<lastBuildDate>Sun, 08 Nov 2009 19:29:21 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Greenbar</title>
		<link>http://www.sitepoint.com/blogs/2004/02/16/line-endings-in-javascript/comment-page-1/#comment-650198</link>
		<dc:creator>Greenbar</dc:creator>
		<pubDate>Sat, 08 Mar 2008 07:06:01 +0000</pubDate>
		<guid isPermaLink="false">706645745#comment-650198</guid>
		<description>How did you get the &quot;greenbar paper&quot; effect found under the &quot;November 2nd, 2006 at 11:13 pm&quot; post?</description>
		<content:encoded><![CDATA[<p>How did you get the &#8220;greenbar paper&#8221; effect found under the &#8220;November 2nd, 2006 at 11:13 pm&#8221; post?</p>]]></content:encoded>
	</item>
	<item>
		<title>By: milanmk</title>
		<link>http://www.sitepoint.com/blogs/2004/02/16/line-endings-in-javascript/comment-page-1/#comment-430825</link>
		<dc:creator>milanmk</dc:creator>
		<pubDate>Tue, 30 Oct 2007 11:00:32 +0000</pubDate>
		<guid isPermaLink="false">706645745#comment-430825</guid>
		<description>I was working on the live preview feature on my blog &lt;a href=&quot;http://efficienttips.com/&quot; rel=&quot;nofollow&quot;&gt;Efficient Tips&lt;/a&gt; and came across the same problem with Firefox which treats line endings and line breaks as &#039;\n&#039;.

I am now using your second solution that first changes everything to &#039;\n&#039; and then replaces the values respectively, as in my case a new line is replaced by &lt;p&gt; and a line ending by &lt;br&gt;.

Thanks for saving my time.</description>
		<content:encoded><![CDATA[<p>I was working on the live preview feature on my blog <a href="http://efficienttips.com/" rel="nofollow">Efficient Tips</a> and came across the same problem with Firefox which treats line endings and line breaks as &#8216;\n&#8217;.</p>
<p>I am now using your second solution that first changes everything to &#8216;\n&#8217; and then replaces the values respectively, as in my case a new line is replaced by &lt;p&gt; and a line ending by &lt;br&gt;.</p>
<p>Thanks for saving my time.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Stephen</title>
		<link>http://www.sitepoint.com/blogs/2004/02/16/line-endings-in-javascript/comment-page-1/#comment-424635</link>
		<dc:creator>Stephen</dc:creator>
		<pubDate>Wed, 24 Oct 2007 16:25:40 +0000</pubDate>
		<guid isPermaLink="false">706645745#comment-424635</guid>
		<description>Also note that if you have a &quot;white-space: nowrap;&quot; style on a textarea in IE then it will treat a \n assigned from JavaScript as a space rather than a line break.

Took me ages to figure out this one...</description>
		<content:encoded><![CDATA[<p>Also note that if you have a &#8220;white-space: nowrap;&#8221; style on a textarea in IE then it will treat a \n assigned from JavaScript as a space rather than a line break.</p>
<p>Took me ages to figure out this one&#8230;</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.sitepoint.com/blogs/2004/02/16/line-endings-in-javascript/comment-page-1/#comment-287833</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Tue, 26 Jun 2007 16:25:44 +0000</pubDate>
		<guid isPermaLink="false">706645745#comment-287833</guid>
		<description>tret
ret
rrt</description>
		<content:encoded><![CDATA[<p>tret<br />
ret<br />
rrt</p>]]></content:encoded>
	</item>
	<item>
		<title>By: yUPdQiqWYG</title>
		<link>http://www.sitepoint.com/blogs/2004/02/16/line-endings-in-javascript/comment-page-1/#comment-151579</link>
		<dc:creator>yUPdQiqWYG</dc:creator>
		<pubDate>Thu, 11 Jan 2007 17:30:21 +0000</pubDate>
		<guid isPermaLink="false">706645745#comment-151579</guid>
		<description>Hi! Very nice site! Thanks you very much! TghvyXzJmSBf</description>
		<content:encoded><![CDATA[<p>Hi! Very nice site! Thanks you very much! TghvyXzJmSBf</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Lucas</title>
		<link>http://www.sitepoint.com/blogs/2004/02/16/line-endings-in-javascript/comment-page-1/#comment-78041</link>
		<dc:creator>Lucas</dc:creator>
		<pubDate>Thu, 02 Nov 2006 13:13:41 +0000</pubDate>
		<guid isPermaLink="false">706645745#comment-78041</guid>
		<description>It seems some of you will find this useful. I was having trouble validating &lt;code&gt;&lt;textarea&gt;&lt;/code&gt;&#039;s until I used an intermediate string which browsers will not meddle with, then if necessary let your server do the line-ending conversions. Obviously this is a very specific implementation but you get the idea.
&lt;pre&gt;&lt;code&gt; function charCount(sourceElem)
 {
  var target=document.getElementById(sourceElem.name+&#039;_count&#039;),
      inputText=sourceElem.value,
      maxLength=500;
  inputText=inputText.replace(/[\r\n]+/g,&#039;\r\n&#039;);
  if(inputText.length&gt;=maxLength)
  {
   target.className=&#039;error&#039;;
   if(inputText.length&gt;maxLength)
   {
    alert(&#039;You have gone over the limit,\nthe end of your input will be trimmed to fit.&#039;);
    inputText=inputText.substring(0,maxLength);
    //fix for
    if(inputText.charAt(maxLength-1)==&#039;\r&#039;)
    {
     inputText=inputText.substring(0,maxLength-1);
     target.className=&#039;&#039;;
    };
    sourceElem.value=inputText;
   };
  }
  else
   target.className=&#039;&#039;;
  target.childNodes[0].nodeValue=inputText.length;
 };
&lt;/code&gt;&lt;/pre&gt;
with &lt;code&gt;&lt;span id=&quot;x_count&quot;&gt;0&lt;/span&gt;/500 character limit&lt;/code&gt; in the body and an &lt;code&gt;onclick=&quot;javascript:charCount(this);&quot;&lt;/code&gt; attribute for the &lt;code&gt;&lt;textarea&gt;&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>It seems some of you will find this useful. I was having trouble validating <code>&lt;textarea&gt;</code>&#8217;s until I used an intermediate string which browsers will not meddle with, then if necessary let your server do the line-ending conversions. Obviously this is a very specific implementation but you get the idea.</p>
<pre><code> function charCount(sourceElem)
 {
  var target=document.getElementById(sourceElem.name+'_count'),
      inputText=sourceElem.value,
      maxLength=500;
  inputText=inputText.replace(/[\r\n]+/g,'\r\n');
  if(inputText.length&gt;=maxLength)
  {
   target.className='error';
   if(inputText.length&gt;maxLength)
   {
    alert('You have gone over the limit,\nthe end of your input will be trimmed to fit.');
    inputText=inputText.substring(0,maxLength);
    //fix for
    if(inputText.charAt(maxLength-1)=='\r')
    {
     inputText=inputText.substring(0,maxLength-1);
     target.className='';
    };
    sourceElem.value=inputText;
   };
  }
  else
   target.className='';
  target.childNodes[0].nodeValue=inputText.length;
 };
</code></pre>
<p>with <code>&lt;span id="x_count"&gt;0&lt;/span&gt;/500 character limit</code> in the body and an <code>onclick="javascript:charCount(this);"</code> attribute for the <code>&lt;textarea&gt;</code></p>]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.sitepoint.com/blogs/2004/02/16/line-endings-in-javascript/comment-page-1/#comment-31809</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Wed, 21 Jun 2006 21:53:59 +0000</pubDate>
		<guid isPermaLink="false">706645745#comment-31809</guid>
		<description>this is a text area and its loses it focus on much heated concentrated daily values</description>
		<content:encoded><![CDATA[<p>this is a text area and its loses it focus on much heated concentrated daily values</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Adams</title>
		<link>http://www.sitepoint.com/blogs/2004/02/16/line-endings-in-javascript/comment-page-1/#comment-3611</link>
		<dc:creator>Chris Adams</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">706645745#comment-3611</guid>
		<description>&lt;p&gt;Why not simply obj.value.replace(/(\r\n&#124;\r&#124;\n)/g, &#039;$1$1&#039;) to double whatever was already there?&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>Why not simply obj.value.replace(/(\r\n|\r|\n)/g, &#8216;$1$1&#8242;) to double whatever was already there?</p>]]></content:encoded>
	</item>
	<item>
		<title>By: dfraize</title>
		<link>http://www.sitepoint.com/blogs/2004/02/16/line-endings-in-javascript/comment-page-1/#comment-3612</link>
		<dc:creator>dfraize</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">706645745#comment-3612</guid>
		<description>&lt;p&gt;I would love to see more CSS design tips and tricks in this section. Great stuff so far!&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>I would love to see more CSS design tips and tricks in this section. Great stuff so far!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Skunk</title>
		<link>http://www.sitepoint.com/blogs/2004/02/16/line-endings-in-javascript/comment-page-1/#comment-3613</link>
		<dc:creator>Skunk</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">706645745#comment-3613</guid>
		<description>&lt;p&gt;Chris: because I didn&#039;t want any existing double newlines to be turned in to quadrupal newlines.&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>Chris: because I didn&#8217;t want any existing double newlines to be turned in to quadrupal newlines.</p>]]></content:encoded>
	</item>
</channel>
</rss>
