自定义谷歌云打印按钮功能 [英] Customize google cloud print button function
本文介绍了自定义谷歌云打印按钮功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当前我正在为我的网站使用google cloudprint按钮
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?
推荐答案
完全没有问题...只需将onclick处理程序附加到打印"按钮,或将单击与jQuery绑定,然后调用一个函数来处理您的电子邮件.我用它在打印之前用Ajax创建了一个文档:
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 :)
这篇关于自定义谷歌云打印按钮功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文