踩到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"); }
The mine has been private property since 1906, and is right now utterly surrounded by Grand Canyon Nationwide Park.
https://zithromax.company/# where to get zithromax
where can i buy zithromax uk
Thank you for the auspicious writeup. It in fact was a amusement account it. Look advanced to far added agreeable from you! However, how could we communicate?
If you are lucky enough to have an exquisite view from an image window in your dwelling room, designate the window as your centerpiece, and compose your furnishings to make the most of it.
Grout reseals the earth below the floor in order that pure ground water aquifers aren’t interrupted.
Day 3, travel from Salzburg to Ljubljana & Zagreb by EuroCity practice, leaving Salzburg Hbf at 14:12, make a fast and simple change at Villach onto a connecting prepare arriving Lesce-Bled 17:50, Ljubljana 18:32 & Zagreb 20:45.
https://semaglutide.win/# rybelsus price
http://stromectol.agency/# ivermectin 5 mg
She loved her work as an LPN as a result of she liked caring for folks, especially her family.
Absent these two circumstances, capital is restricted in its skill to accumulate: it may neither produce nor sell on a mass scale.
Профессиональный сервисный центр сервисный центр мобильных телефонов ремонт смартфона
Hi there, My title is omvir singh a management put up graduate interested to begin a exhibition in my metropolis.
Профессиональный сервисный центр по ремонту бытовой техники с выездом на дом.
Мы предлагаем: сервис центры бытовой техники воронеж
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!
Long additionally performed Brandi in Boyz n the Hood.
Overall, making a cinder block bench at home is an inexpensive and artistic manner so as to add seating options to any outdoor area.
While such systems were as soon as widespread in cold areas, after several fires which were not controlled because of sprinkler techniques crammed with too high a share of antifreeze, the regulatory authority in the United States effectively banned new antifreeze installations.
Aller (who’s a monetary adviser), a library that doubles as a guest room, and a studio for Mrs.
4, 1998 in De Queen Regional Medical Heart.
generic zithromax azithromycin: zithromax for sale – where to buy zithromax in canada
Тут делают продвижение разработка мед сайтов создать сайт медицинского центра
cheap Rybelsus 14 mg: buy semaglutide online – Rybelsus 14 mg
minocycline manufacturer stromectol price ivermectin 500mg
https://gabapentin.auction/# neurontin price australia
buy stromectol pills stromectol price minocycline 100 mg without doctor
http://gabapentin.auction/# neurontin 100mg caps
http://amoxil.llc/# amoxicillin without prescription
Застройщик жк резиденция лайф сэкономил на всем, низкое качество. Не рекомендую иметь дело с группой компаний паритет девелопмент. Звоните все расскажу: @dontcheatpeople – телеграмм.
https://zithromax.company/# zithromax prescription in canada
Hi to аll, the contents preѕent att tһis web page arе reаlly awesome fߋr people experience,
ᴡell,keep սρ the nice work fellows.
Stop ƅy myy blog … بهترین مشاور کنکور آنلاین و ارزان
Интернет-магазин плитки и керамики «ИнфоПлитка»
Интернет-магазин керамической плитки и керамогранита «Infoplitka» (infoplitka.ru)
предлагает широкий ассортимент высококачественной плитки и керамогранита от ведущих производителей.
Мы стремимся предложить нашим клиентам только лучшее, поэтому в ассортименте представлены товары,
отвечающие самым высоким стандартам качества и дизайна.
Мы понимаем, что выбор керамической плитки и керамогранита – это важный этап в создании
комфортного и стильного интерьера. Поэтому наша команда профессионалов готова помочь вам в
подборе идеального варианта для вашего проекта. Независимо от того, нужны ли вам плитка
для ванной комнаты, кухни, гостиной, или же керамогранит для облицовки пола, вы всегда найдете
у нас разнообразные и актуальные коллекции, соответствующие последним тенденциям в области
дизайна интерьеров.
Официальный сайт «ИнфоПлитка»