动态@media打印样式表编辑

时间:2016-10-19 14:57:29

标签: javascript c# jquery css asp.net

我测试了这个功能,并注意到打印页面根本没有根据else语句改变。有什么我做错了吗?

function handlePrint(event) {

        var id = 'report-display';

        var iframe = document.frames ? document.frames[id] : document.getElementById(id);
        paginateReport = $("#paginateCheckBox").prop("checked");
        if (!paginateReport) {
            //parent.document.getElementById("#pageBreaker").style.pageBreakAfter = "auto";


        }
        else
        {
            //parent.document.getElementById("#pageBreaker").style.pageBreakAfter = "always";
            $('head').append('<style type="text/css" media="print">.pageBreak {page-break-after: always;} .pageBreak:last-of-type{page-break-after: avoid;}}</style>');
        }
        var ifWin = iframe.contentWindow || iframe;
        ifWin.focus();
        ifWin.printPage();
        return false;
    }

0 个答案:

没有答案