我有一个图表,一个日期选择器(日历)和几个按钮的PHP页面。打印一个URL的内容 - javascript
我想添加另一个按钮“打印图表”,它只在本地打印机上打印图表&而不是整个页面 。
我试图通过具有另一脚本(仅输出图)和使用JavaScript函数 'window.print'
HTML做到这一点
<input type="button" onClick="printChart()" value="Print Chart">
的javascript
function printChart(){
var myParameters = window.location.search;// Get the parameters from the current page
var URL = "http://my_server/my_folder/my_script_that_outputs_only_my_chart.php"+myParameters;
var W = window.open(URL);
W.window.print(); // Is this the right syntax ? This prints a blank page and not the above URL
}
我试过上面的代码 - 它不工作。打印一张空白页。
有没有办法打印目标网址?如果是,是否可以打印而不必打开新窗口?
感谢您的时间
适合打印的页面已成为过去。使用打印样式表。 – 2009-07-07 21:23:54
如果这是太多的工作,试试这个:W.onload = function(){print(); } – 2009-07-07 21:24:45