踩到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"); }
farmacie online autorizzate elenco: Cialis generico controindicazioni – comprare farmaci online all’estero
comprare farmaci online con ricetta: Farmacia online migliore – migliori farmacie online 2024
Pretty nice post. I just stumbled upon your weblog and wanted to say that I’ve truly enjoyed browsing your blog posts. After all I will be subscribing to your feed and I hope you write again very soon!
https://ultramarine-freesia-dc4vld.mystrikingly.com/blog/004269cf7ad
https://maroon-cat-dc4vlw.mystrikingly.com/blog/a1f40de2c25
I’m in awe of the way you handle topics with both grace and authority.
farmacia online: Avanafil a cosa serve – acquisto farmaci con ricetta
A chainsaw amnesty is protecting the rainforest in Borneo
обувь персей ортопедическая
Borneo was once covered in lush, dense rainforests, but they are rapidly disappearing. The Southeast Asian island, roughly three times the size of the UK, has lost half its forest cover since the 1930s, destroying precious habitat for wildlife such as the critically endangered orangutan, as well as valuable carbon stores.
A non-profit called Health in Harmony (HIH) is asking farmers to hand in their chainsaws in return for money, and a chance to set up an alternative livelihood.
Borneo is divided between Indonesia, Malaysia and Brunei, and it is estimated that up to 10% of its land is taken up by industrial palm oil and logging operations. But deforestation isn’t just about large-scale tree clearance; some of those behind the logging are small-scale farmers, cutting trees as a sideline to make ends meet.
Buyback and healthcare
HIH launched its chainsaw buyback scheme in 2017, under the group’s Indonesian name, Alam Sehat Lestari (ASRI). Farmers who illegally log and sell the wood to timber companies are given around $200 for their chainsaws, as well as up to $450 in financial support for them to set up an alternative, sustainable livelihood, such as opening a shop, organic farming and even beekeeping.
The scheme also involves addressing the root causes of the problem. According to HIH, many of the farmers who turn to logging do so because they need the money for basics like healthcare.
“They live far from the healthcare clinics, and they see logging as a place where they can get quick cash,” explained Mahardika “Dika” Putra, conservation program manager at HIH. “If they need this amount of money, they cut this amount of trees.
“We asked what solutions they think they need to live in harmony with the forest and they said, ‘high quality, affordable healthcare, and training in organic farming.’”
The insights are like keys, unlocking new perspectives and ideas I hadn’t considered.
https://medium.com/@nsw5288/%EB%B9%84%EC%95%84%EA%B7%B8%EB%9D%BC-%ED%95%9C%EC%95%8C-%EA%B0%80%EA%B2%A9-583a77ab8744
Good site! I truly love how it is easy on my eyes it is. I am wondering how I might be notified when a new post has been made. I’ve subscribed to your RSS which may do the trick? Have a great day!
비아그라 제네릭
비아그라 제네릭: 효과, 이점, 그리고 주의사항
comprare farmaci online all’estero: acquisto farmaci con ricetta – Farmacia online miglior prezzo
farmacie online affidabili: Farmacie online sicure – farmacie online affidabili
Are the issues really as complex as they seem?
Добрый день!
Официальная покупка школьного аттестата с упрощенным обучением в Москве
rushkas-diplomxx.ru/kupit-diplom-instituta
Добрый день!
Заказать диплом университета.
mandiplomik.ru/svidetelstvo-o-rozhdenii-sssr1
Farmacie on line spedizione gratuita: Avanafil 50 mg – п»їFarmacia online migliore
https://t.me/iv?url=https://www.via-st365.com/
I’m in awe of the way you handle topics with both grace and authority.
acquistare farmaci senza ricetta: Farmacie online sicure – migliori farmacie online 2024
transport car across country transport car across country .
https://xn--gx-2e2i723b91ktjas9l307b.mystrikingly.com/blog/7511bf36dab
viagra originale in 24 ore contrassegno: viagra senza prescrizione – viagra 50 mg prezzo in farmacia
The work is truly inspirational. I appreciate the depth you bring to The topics.
I?m now not sure where you are getting your information, however great topic. I needs to spend some time studying much more or understanding more. Thanks for wonderful info I used to be looking for this info for my mission.
acquistare farmaci senza ricetta: Cialis generico controindicazioni – acquisto farmaci con ricetta
비아그라(실데나필)의 효과를 극대화하는 몇 가지 방법은 다음과 같습니다:
비아그라의 효과를 극대화하는 방법
The Writing has become a go-to resource for me. The effort you put into The posts is truly appreciated.
https://aqua-leopard-dc4vlz.mystrikingly.com/blog/a1f4b32e03d