使用jquery打印图像不起作用
Print Image with jquery dont work
Hy Guys。。。
我有一些lightbox脚本,可以在其中构建自定义按钮。我做了一个按钮来打印灯箱中显示的图像。。但图像没有出现在打印窗口上(在谷歌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";(打印)。。我做错了什么?
泰寻求帮助!
编辑:这是问题的链接。点击DropDown 上的某些项目
您应该打开一个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(谷歌第一次点击)。
相关文章:
- 使用css()设置背景图像;不起作用
- 图层删除(图像);在 Kinetic.js 中不起作用
- 为什么我的图像幻灯片不起作用
- 为什么这个jQuery图像映射在WordPress上不起作用
- 在页面中使用了两次多个图像上传,但第一个正在工作,另一个不起作用
- 用于图像上传的 ng 文件上传不起作用
- 当图像和链接是 json 对象属性的值时,它们不起作用
- JavaScript 图像加载器不起作用
- 本地存储功能中的图像不起作用
- 使用 nameProp 的 JQuery 图像滚动更新在 Firefox 和 Chrome 中不起作用
- 如果图像具有 guid 作为名称,则 jqZoom 不起作用
- jQuery图像淡入淡出不起作用
- 输入类型的图像在Internet Explorer中不起作用,但在Chrome和Firefox中起作用
- Transloadit-图像自动旋转不起作用
- 滚动过标题后显示图像-尝试不起作用
- 上传前查看图像在IE中不起作用
- 简单的 Java 脚本背景图像不起作用
- 图像预览在Safari中不起作用
- ajax加载图像第二次在弹出jquery上不起作用
- Jquery setTimeout 不起作用(图像幻灯片)