踩到Window resize在Preview print的雷
最近在作案的過程中遇到一個狀況,從Art design那邊拿到的頁面,會在Window resize的時候執行某個Function,本來一切都正常,但測試到Chrome和Firefox預覽列印時發現也會Trigger這個Event,會讓在預覽列印過後的頁面發生問題,所以必須要進行修正,以下是這個案例的說明:
先在測試頁加入以下的程式,發現在預覽列印的時候會Trigger window resize event:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Preview Print Test</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script> $(window).resize(function() { console.log("Window Resize"); }); </script> </head> <body> <h1>Window Resize Test</h1> </body> </html>


網路上搜尋了一下解決方案,將Script改寫如下,可以順利解決,但不知道是不是最好的方法,如果大家有更好的也別忘了告訴我唷~
openResizeFn(); // Chorme var print = false; var mediaQueryList = window.matchMedia('print'); mediaQueryList.addListener(function (mql) { if (mql.matches) { closeResizeFn(); } else { setTimeout(openResizeFn, 2000); } }); // Firefox window.onbeforeprint = function () { closeResizeFn(); }; window.onafterprint = function () { setTimeout(openResizeFn, 2000); }; // Common Function function openResizeFn() { $(window).on("resize", windowResize); } function closeResizeFn() { $(window).off("resize", windowResize); } function windowResize() { console.log("Window Resize"); }
A trusted partner in my healthcare journey.
cost of generic cytotec without dr prescription
They offer invaluable advice on health maintenance.
мостбет кыргызстан скачать http://chesskomi.borda.ru/?1-10-0-00000277-000-0-0-1741171219/ .
Making global healthcare accessible and affordable.
https://cipropharm24.top/
They’re globally renowned for their impeccable service.
Their international health workshops are invaluable.
can i purchase generic clomid for sale
Their multilingual support team is a blessing.
Their online chat support is super helpful.
how to buy cytotec price
Their pharmacists are top-notch; highly trained and personable.
dark market link https://github.com/nexusdarkneturlwrf4t/nexusdarkneturl – darkmarket list
darknet site https://github.com/aresmarketlink0ru72/aresmarketlink – dark market list
1 win https://www.aqvakr.forum24.ru/?1-3-0-00001121-000-0-0 .
dark web link https://github.com/darknetmarketlistv8tg0/darknetmarketlist – dark market 2025
mostbet промокод http://chesskomi.borda.ru/?1-10-0-00000277-000-0-0-1741171219/ .
1vin kg http://aqvakr.forum24.ru/?1-3-0-00001121-000-0-0/ .
darknet marketplace https://github.com/darknetmarketlinks2025/darknetmarkets – darknet market lists
мостюет http://chesskomi.borda.ru/?1-10-0-00000277-000-0-0-1741171219/ .
Their home delivery service is top-notch.
where can i buy cheap clomid without prescription
Quick turnaround on all my prescriptions.
Hi! Someone in my Facebook group shared this website with us so I came to check it out. I’m definitely loving the information. I’m book-marking and will be tweeting this to my followers! Fantastic blog and great design and style.
A pharmacy that breaks down international barriers.
does cymbalta interact with gabapentin
Their loyalty points system offers great savings.
darkmarket link https://github.com/aresmarketlink0ru72/aresmarketlink – dark market link
The best place for health consultations.
п»їcan i purchase cheap lisinopril without a prescription
Their worldwide outreach programs are commendable.
dark market https://github.com/nexusdarkneturlwrf4t/nexusdarkneturl – darknet websites
Their global health insights are enlightening.
can i take gabapentin if pregnant
The best choice for personalized care.
dark web markets https://github.com/darknetmarketlistv8tg0/darknetmarketlist – dark web link
Their international patient care is impeccable.
where to buy cipro without a prescription
Their global health initiatives are game-changers.
I’ve thought about posting something about this before. Good job! Can I use part of your post in my blog?
1win сайт https://cah.forum24.ru/?1-13-0-00001560-000-0-0-1741172791 .
darknet marketplace https://github.com/darknetmarketlinks2025/darknetmarkets – dark market url
dark web market urls https://github.com/tormarkets2025ukaz1/tormarkets2025 – darknet market list
darknet market links https://github.com/aresmarketlink0ru72/aresmarketlink – darknet markets 2025
Just came from google to your website have to say thanks.
They bridge the gap between countries with their service.
https://lisinoprilpharm24.top/
Love the seasonal health tips they offer.
Порно чат рулетка бесплатно, без регистрации