我想知道是否有跨浏览器的打印代码,也就是说,如果我需要更简单的代码:
//print page
$('.print').click(function() {
window.print();
return false;
});我确实找到了书签,这就是为什么我更关心印刷,但在谷歌上找不到任何有用的东西。
以下代码用于跨浏览器的书签
//bookmark page
$("a.bookmark").click(function(e)
{
e.preventDefault(); // this will prevent the anchor tag from going the user off to the link
var bookmarkUrl = this.href;
var bookmarkTitle = this.title;
if (window.sidebar) { // For Mozilla Firefox Bookmark
window.sidebar.addPanel(bookmarkTitle, bookmarkUrl,"");
} else if( window.external || document.all) { // For IE Favorite
window.external.AddFavorite( bookmarkUrl, bookmarkTitle);
} else if(window.opera) { // For Opera Browsers
$("a.jQueryBookmark").attr("href",bookmarkUrl);
$("a.jQueryBookmark").attr("title",bookmarkTitle);
$("a.jQueryBookmark").attr("rel","sidebar");
} else { // for other browsers which does not support
alert('Your browser does not support this bookmark action');
return false;
}
});发布于 2011-09-18 09:55:28
window.print()是事实上的标准。(它在IE4/Netscape 4时代就得到了支持)。
在此过程中,请务必了解如何在使用print-specific CSS stylesheets打印页面时自定义页面外观。
发布于 2011-09-18 09:35:31
window.print()将会完成这项工作。
发布于 2011-09-18 09:36:37
这是一般的方法。它不是dom的官方部分。我会先检查它的存在。
https://stackoverflow.com/questions/7458948
复制相似问题