簡體   English   中英

單擊按鈕后更改打印樣式

[英]change print style after button click

這個:

<link id="printstyle" href="oldprintstyle.css" rel="stylesheet" type="text/css" media="print" />

$('#printStyle2').click(function () {
    $("#printstyle").attr('href', _printStyle2);
    window.print();
    return false;
});

種作品。 我說的是這樣,因為實際的打印樣式僅在第二次單擊ID為'printStyle2'的按鈕后才應用。 發生這種現象的原因可能是什么? 某種舊打印樣式的緩存?

瀏覽器確實需要一些時間才能應用所有更改。 所以:

window.setTimeout(function() { window.print(); }, 1000);

絕招。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM