문제

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?

도움이 되었습니까?

해결책

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 :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top