踩到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"); }
Kasino di Indonesia menyediakan hiburan yang beragam http://preman69.tech/# Pemain bisa menikmati slot dari kenyamanan rumah
http://bonaslot.site/# Kasino menyediakan layanan pelanggan yang baik
Slot menjadi daya tarik utama di kasino: preman69 slot – preman69 slot
garuda888.top garuda888 slot Banyak pemain mencari mesin dengan RTP tinggi
http://slot88.company/# Permainan slot mudah dipahami dan menyenangkan
Kasino sering memberikan hadiah untuk pemain setia https://bonaslot.site/# Slot klasik tetap menjadi favorit banyak orang
Mesin slot sering diperbarui dengan game baru: preman69 slot – preman69
Pemain bisa menikmati slot dari kenyamanan rumah http://slotdemo.auction/# Bermain slot bisa menjadi pengalaman sosial
Thieves blow up museum door and steal ancient artifacts, including 2,500-year-old gold helmet
анальный секс можно
Thieves have stolen four ancient artifacts, including an approximately 2,500-year-old gold helmet, after using explosives to break into a museum in the Netherlands.
The daring heist took place at Drents Museum in Assen during the early hours of Saturday morning, according to Dutch police, who said they received a report of an explosion at 3:45 a.m. local time.
CCTV footage released by police shows the suspects opening an exterior door before a blast sends sparks and smoke into the air. The thieves made off with three gold bracelets, dating from around 50 BC, as well as the 5th-century BC Helmet of Cotofenesti, a historically important artifact on loan from the National History Museum of Romania in Bucharest.
The items were part of an exhibition about the Dacians, an ancient society that occupied much of present-day Romania before being conquered by the Romans. On show since July, “Dacia: Empire of Gold and Silver” featured treasures borrowed from institutions across Romania.
In a press release on its website, Drents Museum described the Helmet of Cotofenesti — which was discovered in a Romanian village almost a century ago — as a “masterpiece.” Its design features mythological scenes and a pair of eyes, located above the wearers’, that were thought to deter enemies during battle while protecting against the “evil eye.”
The exhibition was set to conclude Sunday, though Drents Museum remained closed through the weekend due to the robbery. Its premises were damaged by the explosion, though no injuries were reported, the museum said.
Dutch police announced that they are working with global police agency Interpol and had, as of Sunday, received more than 50 tip-offs. Investigators are currently looking for information about a gray car that was stolen from the nearby city of Alkmaar earlier in the week and was discovered around four miles from the crime scene, on fire, shortly after the overnight heist.
Slot menawarkan berbagai jenis permainan bonus https://garuda888.top/# Slot klasik tetap menjadi favorit banyak orang
Permainan slot bisa dimainkan dengan berbagai taruhan http://garuda888.top/# Kasino menawarkan pengalaman bermain yang seru
preman69.tech preman69 Kasino selalu memperbarui mesin slotnya
Slot dengan bonus putaran gratis sangat populer https://bonaslot.site/# Kasino menawarkan pengalaman bermain yang seru
Banyak pemain berusaha untuk mendapatkan jackpot: bonaslot – BonaSlot
Mesin slot dapat dimainkan dalam berbagai bahasa: garuda888 slot – garuda888.top
http://garuda888.top/# Beberapa kasino memiliki area khusus untuk slot
https://garuda888.top/# Kasino memastikan keamanan para pemain dengan baik
slot88.company slot88.company Slot klasik tetap menjadi favorit banyak orang
Permainan slot mudah dipahami dan menyenangkan https://bonaslot.site/# Mesin slot sering diperbarui dengan game baru
Slot dengan pembayaran tinggi selalu diminati https://preman69.tech/# Mesin slot dapat dimainkan dalam berbagai bahasa
http://slotdemo.auction/# Pemain sering berbagi tips untuk menang
http://preman69.tech/# Kasino memiliki suasana yang energik dan menyenangkan
Slot dengan pembayaran tinggi selalu diminati http://preman69.tech/# Banyak kasino memiliki promosi untuk slot
Bermain slot bisa menjadi pengalaman sosial: slot 88 – slot 88
http://bonaslot.site/# Slot dengan bonus putaran gratis sangat populer
Mesin slot sering diperbarui dengan game baru http://garuda888.top/# Mesin slot menawarkan pengalaman bermain yang cepat
Kasino memastikan keamanan para pemain dengan baik: bonaslot – bonaslot
Slot dengan bonus putaran gratis sangat populer http://slot88.company/# Jackpot progresif menarik banyak pemain
Slot dengan pembayaran tinggi selalu diminati https://slot88.company/# Pemain sering berbagi tips untuk menang
Banyak kasino memiliki program loyalitas untuk pemain https://bonaslot.site/# Slot klasik tetap menjadi favorit banyak orang