How to run Browser command using jQuery / Javascript?

Tags: , , ,



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.

Javascript/jQuery solution preferred.

Answer

For printing you can use window.print().

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

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



Source: stackoverflow