Javascript Help

I am trying to Print the contents of the textarea and in all browsers except IE8.0.6001, it works fine

<script language="javascript">
function printerfriendly() {
  childWin = open("", "childWin", "location=yes, menubar=yes, toolbar=yes, scrollbars=yes");
  var text = document.printfrm.editDetails.value;
  childWin.document.write(text);
}
</script>

what happens is when i click the-print button, it banks empty page and below shows the image is being downloaded, it keeps waiting unless and until i press the refresh[f5] and then it appears OK,

other browsers, it works fine

can anyone guide why this stupid IE behavior
LVL 16
Gurpreet Singh RandhawaWeb DeveloperAsked:
Who is Participating?
 
RoonaanConnect With a Mentor Commented:
Try replacing:
childWin.document.write(text);

Open in new window

with
childWin.document.open();
childWin.document.write(text);
childWin.document.close();

Open in new window

0
 
Tom BeckCommented:
I would try a different syntax on this line:

var text = document.printfrm.editDetails.value;

Perhaps:

var text = document.forms[0].editDetails.value;

Or:

var text = document.getElementById("editDetails").value;
0
 
Gurpreet Singh RandhawaWeb DeveloperAuthor Commented:
Can you explain it Please why it worked this way
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.