本文介绍了跨浏览器打印命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有任何跨浏览器的打印代码,也就是说如果我需要其他的,只需简单:

i want to know if there is any cross-browser print code, that is if i need other then just simple:

//print page
    $('.print').click(function() {
        window.print();
        return false;
    });

我发现为书签,这就是为什么我更关心打印,但找不到

i did found for bookmark and thats why i was more concern about print too, but couldn't find anything useful on google.

以下代码用于书签跨浏览器

following code is for bookmark cross-browser

//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;
    }
});


推荐答案

window.print 。 (自从IE4 / Netscape 4开始支持)。

window.print() is a de-facto standard. (it's been supported since the days of IE4/Netscape 4).

在使用它时,请务必查看如何自定义网页的外观它是使用打印的。

While you're at it, be sure to check out how you can customize how your page looks when it's printed using print-specific CSS stylesheets.

这篇关于跨浏览器打印命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 21:09