3

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.

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

try: (this is just for "save as") ripped and edited from here

<html>
<head>

<script src="http://code.jquery.com/jquery-latest.js"></script>

<script >
$(document).ready(function(){
$('a#save').click(function() {
        if (!!window.ActiveXObject) {
            document.execCommand("SaveAs");
        } else if (!!window.netscape) {
            var r=document.createRange();
            r.setStartBefore($("head")[0]);
            var oscript=r.createContextualFragment('<script id="scriptid" type="application/x-javascript" src="chrome://global/content/contentAreaUtils.js"><\/script>');
            $('body').append(oscript);
            r=null;
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                saveDocument(document);
            } catch (e) {
                //no further notice as user explicitly denied the privilege
            } finally {
                //re-defined
               $("#scriptid").remove();
            }
        }
   return false;
    })
})
</script>
</head>
<body>
<a href="#" id="save">save the document</a>
</body>
</html>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.