1

Is there a way to disable javascript when a page is printed?

I have created print specific stylesheets, but when I print preview the javascript is still interacting with some elements (such as cascades which hide portions of content etc).

When its being printed I would like ALL javascript disabled. Is this even possible?

4

1 回答 1

1

编辑后

您可以使用

window.onbeforeprint = function() { }

window.onafterprint = function() { }

在 webkit 上确定这应该可以

var mediaQuery = window.matchMedia('print');
mediaQuery.addListener(function(mql) {
    if(mql.matches) {
        console.log('before print');
    }
    else {
        console.log('after print');
    }
});
于 2013-07-25T19:48:21.903 回答