Get a very large string in javascript variable
<p>I am writing a webpage for reading notices/messages which requires me to take the notice as input from a database. I am taking the input using php and passing it to a javascript function using echo.</p>

<p>Now the  problem is that if the notice is very large(>1000 characters or something) the function stops working. Is there a way to store large strings in javascript variables?</p>

<p>Thankn you in advance.</p>

<p>The javascript function goes like this:</p>

<pre><code>function display(subject, notice, from,to)
{
    alert(notice);
    document.getElementById('reader_default').innerHTML='';
    document.getElementById('subject').innerHTML="SUBJECT : "+subject;
    document.getElementById('from').innerHTML="From: "+from;
    document.getElementById('to').innerHTML="To: "+to;
    document.getElementById('noticedisp').innerHTML=""+notice;
}
</code></pre>

<p>The php variable pass goes like:</p>

<pre><code>echo '&lt;a href="javascript:void(0)" onclick="display(\''.ucfirst($subject).'\',\''.$notice.'\',\''.ucfirst($hostel).' Hostel'.'\',\''.$toid.'\')" style="padding:2%; text-decoration:none; color:#0033CC;"&gt;'.ucfirst($subject).'&lt;/a&gt;'.'&lt;br /&gt;&lt;span style="padding:2%;"&gt;&lt;i&gt;From: &lt;/i&gt;'.ucfirst($hostel).'Hostel&lt;/span&gt;&lt;br/&gt;'.'&lt;br/&gt;&lt;br/&gt;';
</code></pre>

<p>First I provided the following string:</p>

<blockquote>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut molestie luctus lectus, nec volutpat ipsum porta sit amet. Phasellus ut egestas sapien. Curabitur mauris erat, eleifend quis adipiscing sollicitudin, posuere tempor ante. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut erat nibh. Maecenas malesuada lacus pulvinar risus placerat convallis. Cras vitae urna in elit aliquam mollis a eu nisi. Nulla id molestie ante. Aenean faucibus interdum nibh, in tristique dui viverra eu. Nulla facilisi. Integer at placerat augue.</p>
  
  <p>Sed quis risus dolor, in tristique est. Maecenas non tellus vel quam blandit elementum. Sed vestibulum dolor non mi eleifend luctus. Proin interdum mollis congue. Fusce quis consequat augue. Integer dictum lectus a ligula egestas in volutpat odio tincidunt. Sed placerat dictum velit quis dapibus.</p>
  
  <p>Cras non quam ut neque auctor hendrerit. Phasellus tincidunt dapibus metus, id rutrum purus fringilla vel. Pellentesque ac sapien elit. Maecenas nibh justo, lobortis id volutpat a, bibendum egestas enim. Vivamus sit amet justo vel tortor ullamcorper molestie ac sed nibh. Donec adipiscing dui sed odio hendrerit quis aliquet turpis posuere. Donec pharetra mi ut odio luctus sodales. Donec elit nisi, cursus elementum cursus at, scelerisque quis ante. Nunc vel ipsum ut nibh dictum tempus ut ut tortor. Donec dignissim pharetra scelerisque. Curabitur pellentesque urna a velit ultricies at lacinia leo euismod. Nulla id dolor ut odio ultrices accumsan in id erat. Aliquam lorem turpis, tristique nec tincidunt id, lacinia sit amet ante. </p>
</blockquote>

<p>When this didn't work after trying everything, I shortened the string to:</p>

<blockquote>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut molestie luctus lectus, nec volutpat ipsum porta sit amet. Phasellus ut egestas sapien. Curabitur mauris erat, eleifend quis adipiscing sollicitudin, posuere tempor ante. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut erat nibh. Maecenas malesuada lacus pulvinar risus placerat convallis. Cras vitae urna in elit aliquam mollis a eu nisi. Nulla id molestie ante. Aenean faucibus interdum nibh, in tristique dui viverra eu. Nulla facilisi. Integer at placerat augue.</p>
</blockquote>

<p>And this works!!</p>
