踩到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"); }
http://doxhealthpharm.com/# doxycycline 25mg
amoxicillin 500 mg for sale: order amoxicillin online no prescription – amoxacillian without a percription
how to get generic clomid no prescription: how can i get cheap clomid without insurance – where buy cheap clomid pill
zithromax for sale 500 mg: ZithroPharm – can you buy zithromax over the counter
doxycycline generic: doxycycline discount – doxycycline tablet 100 mg
You might have the ability to get away with carrying a decrease SPF sunscreen than your fair mates, though.
where to buy cheap clomid prices get generic clomid without rx can i order generic clomid without rx
doxycycline 40mg capsules: doxycycline 50 mg price uk – doxycycline canada pharmacy
https://zithropharm.shop/# zithromax 500mg
https://doxhealthpharm.shop/# doxycycline 150 mg tablets
where buy cheap clomid now: can i purchase clomid – where buy cheap clomid without insurance
where to buy generic clomid now: ClmHealthPharm – order clomid without a prescription
purchase amoxicillin online Amo Health Pharm amoxil pharmacy
It will be significant for fogeys and caregivers to be conscious of their interactions with infants and provide constant and nurturing care to encourage the development of secure attachment.
where can i buy zithromax capsules: buy azithromycin zithromax – zithromax z-pak price without insurance
where buy clomid without a prescription: ClmHealthPharm – can i purchase clomid price
get cheap clomid for sale: ClmHealthPharm – clomid brand name
buy zithromax online with mastercard zithromax antibiotic without prescription zithromax coupon
zithromax tablets for sale: ZithroPharm – can you buy zithromax over the counter in australia
generic zithromax azithromycin: Zithro Pharm – how to get zithromax online
Вакансии Москва – Метро Москвы, Ищу модель Москва
This is the wave – the big wave.
Москва с вами – Ищу модель Москва, Город Москва
http://clmhealthpharm.com/# how to get generic clomid without prescription
doxycycline rx coupon DoxHealthPharm price of doxycycline
doxycycline capsules purchase: Dox Health Pharm – where to get doxycycline
amoxicillin online without prescription: amoxicillin online purchase – generic amoxicillin cost
can i buy cheap clomid price: ClmHealthPharm – where buy cheap clomid
amoxicillin pharmacy price: AmoHealthPharm – generic amoxicillin cost
Подслушано Москва – Население Москвы, Барахолка Москва