window.print

function contentPrint(contentArea) {

    var initBody = document.body.innerHTML;



    if ($("div").hasClass("scroll")) {

        $(".scroll").attr("class", "");

    }



    if (window.matchMedia) {

        var mediaQueryList = window.matchMedia('print');

        mediaQueryList.addListener(function (mql) {

            if (mql.matches) {

                document.body.innerHTML = document.getElementById(contentArea).innerHTML;

            } else {

                document.body.innerHTML = initBody;

            }

        });

    }



    window.onbeforeprint = function () {

        document.body.innerHTML = document.getElementById(contentArea).innerHTML;

    }

    window.onafterprint = function () {

        document.body.innerHTML = initBody;

    }



    window.print();

}

 

你可能感兴趣的:(window)