Oops Posted May 31, 2007 Report Share Posted May 31, 2007 Hi Im rendering my chart as an image and when i try to print it out using javascript im getting lots of additional garbage coming into the html that im supposed to get from the element.It looks like elements of the toolbar (i get the Load my chart icon and label, save my chart icon and label, restore defaults icon and label and the icons for all the galleries, and then som e colour palettes) Because my toolbar is disabled i cant understand why this is happening. My javascript looks like so: var prtContent1 = document.getElementById(Chart1); var WinPrint = window.open('','','left=0,top=0,width=0,height=0,toolbar=0,scrollbars=0,status=0,resizable=0,menubar=0,'); WinPrint.document.write(prtContent1.innerHTML); WinPrint.document.close(); WinPrint.focus(); WinPrint.print(); WinPrint.close(); Any ideas ? Thanks Link to comment Share on other sites More sharing options...
Frank Posted May 31, 2007 Report Share Posted May 31, 2007 I don't understand this code. What are you trying to do? What is Chart1, shouldn't it be 'Chart1'? But it it is, prtContent1.innerHTML, will be nothing if the chart is an Image tag. It seems that what you are getting is the page without the stylesheets. If what you are trying to do is print the chart, the follwoing script will do it: function SFX_PrintImage (imgId) { var chartImage = document.getElementById('Chart1');var imgSrc = chartImage.src; var w = window.open ('', '_blank', 'menubar=0,location=0,status=0,resizable=0,scrollbars=0,titlebar=0,status=0,toolbar=0,linkbar=0,width=1,height=1');var html = '<HEAD><TITLE>Chart</TITLE></HEAD><HTML><BODY ONLOAD="if (window.print) { setTimeout(\'window.close()\', 1); window.print(); }">'; html += '<IMG SRC="' + imgSrc + '">';html += '<\/BODY><\/HTML>'; w.document.open(); w.document.write(html); w.document.close(); } Link to comment Share on other sites More sharing options...
Oops Posted June 3, 2007 Author Report Share Posted June 3, 2007 Thanks that fixed it, i was actually trying to add on the contents of the chart to a new html page and then add on the contents of a few other items to the page. Cheers. Link to comment Share on other sites More sharing options...
Frank Posted June 11, 2007 Report Share Posted June 11, 2007 Excellent! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.