调用window.print在IE浏览器不工作 [英] call to window.print not working in IE

查看:810
本文介绍了调用window.print在IE浏览器不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个asp.net页面内容我有一个超链接,我正在呼吁window.print ..但它不工作,不打开打印窗口。

In a asp.net content page I have a hyperlink and I am making call to window.print.. but its not working, not opening the print window.

<a href="javascript:window.print(); return false;" style="border:none" >
    <input type="image" src="print.png" alt="" />
</a>

任何想法,为什么?

any ideas why?

感谢

推荐答案

建议的的在的href 使用JavaScript。试试这个:

I suggest not using javascript in the href. Try this instead:

<a href="#" onclick="window.print(); return false;" style="border:none" >
    <input type="image" src="print.png" alt="" />
</a>

就个人而言,我不喜欢加入任何内嵌的JavaScript我的元素。所以,我这样做:

Personally, I don't like adding any inline JavaScript to my elements. So, I would do this:

CSS:

#printPage{
    cursor: pointer;
}

HTML

<input type="image" src="print.png" alt="" id="printPage" />

JavaScript的:

JavaScript:

document.getElementById('printPage').addEventListener('click', function(){
    window.print();
});

DEMO: http://jsfiddle.net/J5MBt/

这篇关于调用window.print在IE浏览器不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆