如何使用jQuery / javascript运行Browser命令? [英] How to run Browser command using jQuery / javascript?

查看:110
本文介绍了如何使用jQuery / javascript运行Browser命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HTML页面,有两个按钮,保存和打印。

I have one page in HTML , there are two buttons , save and print.

当用户点击打印它应该打印页面和
当用户点击保存页面时,它应该打开另存为...该页面的框。

When user click on the Print it should print the page and When user click on the Save page it should Open Save as... Box for that page.

javascipt / jquery solution preferred。

javascipt/jquery solution preferred.

谢谢。

推荐答案

对于打印,您可以使用 window.print()

For printing you can use window.print().

没有标准方法可以触发保存对话框。在IE中,您可以使用 document.execCommand('SaveAs')

There is no standard way to trigger the Save dialog. In IE you can use document.execCommand('SaveAs').

编辑 :技术上 window.print 不是任何标准的一部分(来源: MDC )但它已广泛使用。

EDIT: Technically window.print isn't part of any standard (Source: MDC) but it's widely available.

这篇关于如何使用jQuery / javascript运行Browser命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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