踩到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"); }
buy gabapentin online gabapentin for sale neurontin 204
https://gabapentin.auction/# neurontin 100mg capsule price
https://semaglutide.win/# semaglutide
zithromax for sale usa
https://zithromax.company/# buy cheap zithromax online
stromectol 15 mg stromectol best price ivermectin 1 cream
http://stromectol.agency/# ivermectin canada
http://stromectol.agency/# stromectol medication
generic stromectol: stromectol for sale – ivermectin 80 mg
http://gabapentin.auction/# neurontin prescription coupon
zithromax coupon
ivermectin pills human: stromectol best price – minocycline 100mg otc
https://semaglutide.win/# Buy semaglutide pills
zithromax 500mg zithromax best price zithromax cost canada
Thanks For This Blog, was added to my bookmarks.
Найти специалиста по независимой экспертизе и оценке!
Сайт-агрегатор компаний и услуг в сфере независимой экспертизы и оценки.
Мы создали этот проект, чтобы помочь вам найти надежных и опытных профессионалов
для решения ваших задач.
Главная цель — сделать процесс поиска специалистов по независимой экспертизе
и оценке максимально простым и эффективным. Мы стремимся предоставить вам
доступ к компаниям, которые гарантируют высокое качество услуг.
С нами вы сможете быстро найти нужного эксперта и сравнить различные предложения.
На нашем сайте собраны карточки компаний, каждая из которых содержит подробную
информацию о предоставляемых услугах. Посетители могут фильтровать предложения
по различным критериям:
Локация
Направление экспертизы
Стоимость услуг
Отзывы клиентов
Наш сайт Специалисты по независимой экспертизе и оценке.
ivermectin buy australia stromectol best price minocycline 50 mg acne
http://zithromax.company/# buy zithromax canada
generic zithromax online paypal
If yoᥙ аre ցoing fⲟr bet ⅽontents lie myѕelf, ϳust visit thiѕ site every day for
the reason tһat it ցives quality cߋntents, tһanks
Here is myy web site – تور قونیه نوروز – 24lancer.ir
https://zithromax.company/# zithromax 1000 mg online
One thing I’d prefer to discuss is that weight loss program fast can be carried out by the correct diet and exercise. A person’s size not only affects appearance, but also the quality of life. Self-esteem, depressive disorders, health risks, and physical skills are damaged in an increase in weight. It is possible to do everything right and at the same time having a gain. In such a circumstance, a medical problem may be the perpetrator. While too much food rather than enough body exercise are usually responsible, common medical conditions and traditionally used prescriptions could greatly add to size. Thanks a bunch for your post right here.
generic zithromax 500mg: order zithromax – zithromax capsules price
https://gabapentin.auction/# prescription drug neurontin
generic augmentin – clavulanate price cheap levothroid generic
https://amoxil.llc/# amoxicillin no prescription
zithromax 500mg
https://amoxil.llc/# amoxil pharmacy
stromectol price: cheapest stromectol – stromectol 3 mg
zithromax 250 mg pill can i buy zithromax online zithromax over the counter
Rybelsus 14 mg Buy compounded semaglutide online rybelsus price
http://semaglutide.win/# buy rybelsus
zithromax 250 mg tablet price
вывод из запоя круглосуточно вывод из запоя круглосуточно .
нарколог на дом вывод из запоя краснодар https://vyvod-iz-zapoya-krasnodar17.ru .