踩到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"); }
как пожаловаться на мошенников как пожаловаться на мошенников .
I?ve been exploring for a bit for any high-quality articles or blog posts on this sort of area . Exploring in Yahoo I at last stumbled upon this site. Reading this info So i?m happy to convey that I have a very good uncanny feeling I discovered just what I needed. I most certainly will make certain to don?t forget this site and give it a look on a constant basis.
feldene tablet – exelon 6mg us exelon for sale
Каждый год в середине сентября проводится Тюменский инновационный форум «НЕФТЬГАЗТЭК».
Форум посвящен определению мнтодов инноваторского продвижения отраслей топливно-энергетического комплекса, рассмотрению а также поиску заключений, организации наилучших условий для формирования инноваторских проектов. Ежегодный тюменский форум представляетсобой влиятельной дискуссионной площадкой по увеличению роста нефтегазовой ветви в Российской Федерации, имеет высокий статус и своевременность, созвучен корпоративной стратегии развития инноваторского направления в Российской Федерации
-https://neftgaztek.ru/
The consistency and high quality of The content are something I really appreciate. Thank you for The dedication.
The take on hard to understand topics is like a smooth ride in a luxury car—comfortable, yet exhilarating.
Brilliant piece of writing. It’s like you’re showing off, but I’m not even mad.
Reading The work is like watching the sunrise, a daily reminder of beauty and new beginnings.
You navigate through topics with such grace, it’s like watching a dance. Care to teach me a few steps?
I admire the way you tackled this hard to understand issue. Very enlightening!
ding modern 비아그라 구매nurseries, e비아그라 구매xperimental 비아그라 구매plot
поисковое продвижение web сайтов http://www.prodvizhenie-sajtov-v-moskve113.ru .
Каталог эротических рассказов https://vicmin.ru подарит тебе возможность уйти от рутины и погрузиться в мир секса и безудержного наслаждения. Обширная коллекция рассказов для взрослых разбудит твое воображение и принесет немыслимое удовольствие.
need to be 비아그라 구매constructed 비아그라 구매without majo비아그라 구매r di
купить квартиру в Санкт-Петербурге от застройщика https://novostroyki-spb78.ru
квартира от застройщика Санкт-Петербург квартиры от застройщика цены
продажа квартир цены квартира от застройщика
The ability to present nuanced ideas so clearly is something I truly respect.
свит бонанза слот http://www.sweet-bonanza-ru.ru/ .
I find myself lost in The words, much like one would get lost in someone’s eyes. Lead the way, I’m following.
A perfect blend of informative and entertaining, like the ideal date night conversation.
Explaining things in an understandable way is a skill, and you’ve mastered it. Thanks for clearing things up for me.
The ability to distill hard to understand concepts into readable content is admirable.
The voice shines through The writing like a beacon, guiding us through the darkness of ignorance.
I’m so grateful for the information you’ve shared. It’s like receiving a thoughtful gift from someone special.
купить квартиру в Санкт-Петербурге от застройщика https://kvartiru-kupit-spb.ru
недорогие квартиры от застройщика https://novostroyka-kzn16.ru
alysis over 비아그라 구매mega cities 비아그라 구매like Delhi a비아그라 구매nd B
купить квартиру в Санкт-Петербурге https://kvartiru-kupit-spb.ru
купить квартиру в новостройке недорого квартиры от застройщика цены