Question

Currently i am using the google cloudprint button for my site

<script src="//www.google.com/cloudprint/client/cpgadget.js"></script>
<script defer="defer">
    var gadget = new cloudprint.Gadget();
    gadget.setPrintButton(document.getElementById("custom_print_button"));
    gadget.setPrintDocument("url", "Cloud Print test page",
                            "http://www.google.com/cloudprint/learn/");
</script>

I want to send an email when I hit the print button, is this possible?

Était-ce utile?

La solution

No problem at all... just attach an onclick handler to the print button, or bind the click with jQuery and call a function to do your email. I used it to create a document with Ajax before it was printed:

<script>
    function printIT() {
        jQuery.ajax({
            url: "print_this.php",
            context: document.body,
            success: function(responseText) {
                alert("Document sent!");
                return false;
            }
        }); 
    }
</script>

<button id="print_button_container" class="ui-link" onclick="printIT();"></button>

<script src="//www.google.com/cloudprint/client/cpgadget.js">
</script>
<script defer="defer">
    var gadget = new cloudprint.Gadget();
    gadget.setPrintButton(document.getElementById("print_button_container"));
    gadget.setPrintDocument("url", "My Document", "http://www.yourpath.com/yourdoc.html");
</script>

Simplified version... not tested but should work :)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top