伙计们..。
我有一些lightbox脚本,我可以在其中构建自定义按钮。我做了一个按钮来打印灯箱中显示的图像..但打印窗口(在Google Chrome、Firefox和IE8上测试过)上看不到图像。这是我的
我的代码:
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#getdropdown").change(function() {
var trial=jQuery("#getdropdown option:selected").val();
jQuery.lightbox(trial,{
buttons: [
{
'class' : 'botao-imprimir',
'html' : 'IMPRIMIR',
'callback' : function(url) {
title = window.open(trial);
//title.document.write(trial);
title.print();
}
}
]
});
});
});
</script>下面是我的HTML:
<select name="getdropdown" class="drop-receitas" id="getdropdown">
<option value="">Escolha aqui a receita desejada</option>
<option value="receitas/image.jpg">Image</option>
<option value="receitas/image2.jpg">Image 2</option>
</select>在var trial上,我有一张图片,当我选择列表中的某个选项时,它会显示带有"IMPRIMIR“(打印)按钮的图片。我哪里做错了?
Ty求救!
编辑:Here是有问题的链接。单击DropDown上的某些项目
发布于 2012-03-02 21:01:49
您应该打开一个窗口对象,该对象指向一个HTML页面,该页面包含标签中的图像。如下所示:
jQuery.lightbox(trial, {
buttons: [
{
'class' : 'botao-imprimir',
'html' : 'IMPRIMIR',
'callback' : function(url) {
var imgWindow = window.open('', 'popup', 'toolbar=no,menubar=no,width=imageWidth,height=imageheight');
imgWindow.document.open();
imgWindow.document.write("<html><head></head><body onload='window.print()'><img src='"+url+"' /></body></html>");
imgWindow.document.close();
}
}
]
});另一种方法是使用打印样式表,它隐藏了图像以外的所有内容。看看这里:http://www.webcredible.co.uk/user-friendly-resources/css/print-stylesheet.shtml (谷歌第一次点击)。
https://stackoverflow.com/questions/9533429
复制相似问题