Microsoft KB Archive/294901

= BUG: Internet Explorer Only Prints First Page of Large TEXTAREA =

Article ID: 294901

Article Last Modified on 8/8/2007

-

APPLIES TO


 * Microsoft Internet Explorer 5.5

-



This article was previously published under Q294901



SYMPTOMS
When you print a TEXTAREA element that is larger than a single page, Internet Explorer only prints the first page of the TEXTAREA.



RESOLUTION
To work around this problem, hide the TEXTAREA element, and copy the contents of each TEXTAREA in a newly created DIV element during the onBeforePrint event. After you print the page, remove the DIV element during the onAfterPrint event, and the TEXTAREA becomes visible again. See the &quot;More Information&quot; section for a code sample that demonstrates this workaround.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
The following code illustrates how to reproduce this problem:   Repro for TEXTAREA not being printed  

function fill_area {   for(i = 0; i < 250; i++) {       mytextarea.value = mytextarea.value + &quot;This is the generated text for the textarea\n&quot;; } } 

  In the actual results, only one page appears in preview, and only one page is printed. In the expected results, several pages should appear in preview, and all of the pages should print.

Workaround
The following code illustrates how to hide the TEXTAREA elements and replace them with DIV elements that contain the contents of the initial TEXTAREA elements:   IE 5.5 TEXTAREA Cropping Workaround</TITLE> </HEAD>

<BODY onload=&quot;fillAreas;&quot; onbeforeprint=&quot;subInDivs;&quot; onafterprint=&quot;putBackTextAreas;&quot;>

<SCRIPT LANGUAGE=&quot;JScript&quot;> function subInDivs {     var collTextAreas = document.all.tags(&quot;TEXTAREA&quot;); var oNewDiv; var sTemp; var i;

for (i = 0; i < collTextAreas.length; i++) {     oNewDiv = document.createElement(&quot;DIV&quot;); oNewDiv.style.width = collTextAreas(i).clientWidth; oNewDiv.style.height = collTextAreas(i).clientHeight; oNewDiv.style.border = &quot;1px solid black&quot;; oNewDiv.id = collTextAreas(i).uniqueID + &quot;_div&quot;;

// Replace all line breaks with HTML line breaks. sTemp = collTextAreas(i).value.replace(/\n/gi,&quot;<BR>&quot;);

// Match two spaces with two non-breaking spaces. sTemp = sTemp.replace(/\s\s/gi,&quot;&#xa0;&#xa0;&quot;);

oNewDiv.innerHTML = sTemp; collTextAreas(i).parentNode.insertBefore(oNewDiv, collTextAreas(i)); collTextAreas(i).style.display = &quot;none&quot;; oNewDiv = null; } }

function putBackTextAreas {  var collTextAreas = document.all.tags(&quot;TEXTAREA&quot;); var oDivToRemove; var i;

for (i = 0; i < collTextAreas.length; i++) {     oDivToRemove = document.all(collTextAreas(i).uniqueID + &quot;_div&quot;); if (oDivToRemove != null) {        oDivToRemove.removeNode(true); }     collTextAreas(i).style.display = &quot;&quot;; }

}

function fillAreas {  var sTempLine = &quot;&quot;; var collTextAreas; var i;

for(i = 0; i < 250; i++) {     //Build string. sTempLine += &quot;Name: Superwolf, Test number: &quot; + i + &quot;, data: XX XXX X XXX XX\n&quot;; }

collTextAreas = document.all.tags(&quot;TEXTAREA&quot;); for (i = 0; i < collTextAreas.length; i++) {     collTextAreas(i).value = sTempLine; } }

</SCRIPT>

<H2>IE 5.5 TEXTAREA Cropping Workaround</H2>

<TEXTAREA ID=&quot;ta1&quot; ROWS=&quot;253&quot; COLS=&quot;70&quot;></TEXTAREA>

</BODY> </HTML>

<div class="references_section">