Hi, im currently rewriting a print script from jQuery to Prototype. It works almost. the main issue as always is explorer. I cant refrence the DOM in my new frame. Explorer says "document is null or not an object". How can i get this ref ? In the script it would be "var objDoc = objFrame.document;" line.
Second issue has to do with images set via css classes wont be printed, They show up alright in the frame but nothing on printed paper. An image set with regular img-tag prints alright though! the originally script can be view here: http://www.bennadel.com/blog/1591-Ask-Ben-Print-Part-Of-A-Web-Page-With-jQuery.htm /* * Prints everything that has a classname of "printable". <a href="#" onclick="print('SE');">print</a> */ function print(lang,classname,header,footer){ if(!classname || classname == "" ){ classname = '.printable'; } if(!header || header == "" ){ header = "def"; } if(!footer || footer == "" ){ footer = "def_"+lang; } var content = ""; //header content += getHeader(header); //Body - collect content to be printed $$(classname).each(function(elm) { content += elm.innerHTML; }); //footer content += getFooter(footer); // Create a random name for the print frame. var strFrameName = ("printer-" + (new Date()).getTime()); // Create an iFrame with the new name. // Hide the frame (sort of) and attach to the body. var ifrm = document.createElement("iframe"); ifrm.setAttribute("name", strFrameName); ifrm.setAttribute("id", "printFrame"); //ifrm.setAttribute("src", ""); ifrm.style.width.value = "800px"; ifrm.style.height.value = "800px"; document.body.appendChild(ifrm); // Get a FRAMES reference to the new frame. var objFrame = window.frames[strFrameName]; // Get a reference to the DOM in the new frame. var objDoc = objFrame.document; // Grab all the style tags and copy to the new document var headTags = document.getElementsByTagName('head')[0].innerHTML; //console.log("headTag: "+headTags); // Write the HTML for the document. In this, we will write out the HTML of the current element. objDoc.open(); objDoc.write( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1- transitional.dtd\">" ); objDoc.write( "<html>" ); objDoc.write( "<body>" ); objDoc.write( "<head>" ); objDoc.write( "<title>" ); objDoc.write( document.title ); objDoc.write( "</title>" ); objDoc.write( headTags ); objDoc.write( "</head>" ); objDoc.write( content ); objDoc.write( "</body>" ); objDoc.write( "</html>" ); objDoc.close(); // Print the document. objFrame.focus(); objFrame.print(); // Have the frame remove itself in about a minute so setTimeout( function(){ $('printFrame').remove(); }, (60 * 1000) ); } function getHeader(key){ var myhash = new Object(); myhash["def"] = '<div><span class="printLogo">image in this class shows up but wont be printed!</span></div>'; return myhash[key] ; } function getFooter(key){ var myhash = new Object(); myhash["def_"] = "<div class='print'></div>"; myhash["def_SE"] = "<div class='print'></div>"; myhash["def_DK"] = "<div class='print'></div>"; myhash["def_NO"] = ""; myhash["def_FI"] = ""; return myhash[key] ; } -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
