从谷歌铬扩展项目使用jQuery的关闭打印预览窗口 [英] Close print preview window from google chrome extension project using jquery
本文介绍了从谷歌铬扩展项目使用jQuery的关闭打印预览窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在制作Google Chrome扩展项目,我需要从我的jquery代码关闭打印预览窗口。当我从我的谷歌浏览器扩展项目调用网站选项时,打印预览窗口会自动打开。
I am making google chrome extension project, where i need to close print preview window from my jquery code. Print preview window open automatically when i call site option from my google chrome extension project.
我也尝试使用--disable-print-preview。在这种情况下打开打印弹出。所以如果有人有想用jQuery关闭打印弹出窗口,那么它也适合我。
取消浏览器打印预览屏幕的解决方案。
这里是解决方案由ErCinAkçay提供
[ I have found the solution to cancel the browser print preview screen. here is the solution provided in Java by "Erçin Akçay"
// Choosing the second window which is the print dialog.
// Switching to opened window of print dialog.
driver.switchTo().window(driver.getWindowHandles().toArray()[1].toString());
// Run javascript code for cancelling print operation.
// This code only executes for Chrome browsers.
JavascriptExecutor executor = (JavascriptExecutor) driver.getWebDriver();
executor.executeScript("document.getElementsByClassName('cancel')[0].click();");
// Switches to main window after print dialog operation.
driver.switchTo().window(driver.getWindowHandles().toArray()[0].toString());
这篇关于从谷歌铬扩展项目使用jQuery的关闭打印预览窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文