Click to See Complete Forum and Search --> : javascript crashed IE


phil_king
12-08-2006, 02:38 AM
Hi,

I wrote the following javascript to implement "printer friendly version" functionality. It works ok sometimes but most of the time it hangs. The popup window appears but freezes and never loads the html. If I put in a alert in the script then it all works fine. Any suggestions?

function Clickheretoprint()
{
var params = getPrintWindowParams();
var head = document.getElementsByTagName("head");
var headcontent = head[0].innerHTML;
var header = document.getElementById("content-header").innerHTML;
var innerhtml = '';
var contentid = '';
var content = document.getElementById("content-cont");

if (content == undefined){
content = document.getElementById("content-full");

}


if (content != undefined){
innerhtml = content.innerHTML;
contentid = content.id;
}

var docprint=window.open("","",params);
docprint.document.write('<html><head>');
docprint.document.write(headcontent);
docprint.document.write('</head><body>');
docprint.document.write('<div id="float-tank"><div id="float-tank-inner">');
docprint.document.write('<div id="content">');
docprint.document.write('<div id="content-header">');
docprint.document.write(header);
docprint.document.write('</div><div id="');
docprint.document.write(contentid);
docprint.document.write('">');
docprint.document.write(innerhtml);
docprint.document.write('</div></div></div></div></div>');
docprint.document.write('</body></html>');

docprint.document.close();


}

Thanks

A1ien51
12-08-2006, 07:34 AM
want to make a printer friendly version without JavaScript? Look into CSS Print Media. Basically it is another style sheet that lets you change the CSS of everything so you can have a print friendly version. Search Google for more details.

Eric