踩到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"); }
https://slot88.company/# Slot dengan tema budaya lokal menarik perhatian
https://slot88.company/# Pemain harus menetapkan batas saat bermain
go to my site https://web-kaspawallet.com/
article https://web-sollet.com/
Your Domain Name https://my-sollet.com
discover here https://my-sollet.com/
navigate to these guys https://web-kaspawallet.com
best site https://web-sollet.com
Slot menawarkan kesenangan yang mudah diakses: slot demo – slot demo rupiah
Banyak pemain menikmati jackpot harian di slot http://bonaslot.site/# Banyak pemain berusaha untuk mendapatkan jackpot
my response https://my-sollet.com/
Сауна очищает организм https://sauna-broadway.ru выводя токсины через пот, укрепляет иммунитет благодаря перепадам температуры, снимает стресс, расслабляя мышцы и улучшая кровообращение. Она делает кожу более упругой, ускоряет восстановление после тренировок, улучшает сон и создаёт атмосферу для общения.
Slot dengan grafis 3D sangat mengesankan: BonaSlot – bonaslot.site
view publisher site https://web-sollet.com
why not try here https://my-sollet.com
go to website https://web-kaspawallet.com
Welcome to PancakeSwap: A Beginner’s Guide
PancakeSwap is a decentralized exchange platform on the Binance Smart Chain, designed for swapping BEP-20 tokens. With its vibrant ecosystem, ease of use, and low transaction fees, it’s become a popular choice among crypto enthusiasts.
Pancakeswap
What is PancakeSwap?
PancakeSwap is an automated market maker (AMM) that allows users to trade directly from their crypto wallets. There’s no order book involved; instead, trades are made against a liquidity pool. Here’s how you can get started:
How to Use PancakeSwap?
Set Up Your Wallet
First, you need a crypto wallet like MetaMask or Trust Wallet. Ensure your wallet supports BEP-20 tokens.
Connect to Binance Smart Chain
Configure your wallet to connect to the Binance Smart Chain network. Detailed guides are available in your wallet settings.
Purchase BNB
You’ll need BNB (Binance Coin) to cover transaction fees. Buy BNB from a reputable exchange and transfer it to your wallet.
Access PancakeSwap
Visit the official PancakeSwap website and connect your wallet by clicking on the ‘Connect Wallet’ button.
Start Trading
Once connected, you can begin swapping BEP-20 tokens. Choose the tokens you wish to trade and confirm your transactions.
Benefits of PancakeSwap
Lower Fees: Operating on Binance Smart Chain, the fees are more affordable than Ethereum-based exchanges.
Fast Transactions: Experience quick transaction speeds due to the efficiency of BSC.
Yield Farming: Earn rewards by providing liquidity or participating in various farming pools.
Conclusion
PancakeSwap offers a user-friendly approach to trading cryptocurrencies, engaging users with its gamified elements like lotteries and collectibles. Whether you’re a beginner or an experienced trader, PancakeSwap provides an efficient and exciting way to dive into the world of decentralized finance. Always ensure to perform your due diligence before engaging in trading activities.
For more detailed guides and support, visit the .
п»їKasino di Indonesia sangat populer di kalangan wisatawan https://slot88.company/# Banyak kasino memiliki promosi untuk slot
this contact form https://my-sollet.com/
Bonuses https://web-kaspawallet.com/
Slot menawarkan berbagai jenis permainan bonus https://bonaslot.site/# Pemain sering mencoba berbagai jenis slot
http://preman69.tech/# Kasino di Indonesia menyediakan hiburan yang beragam
Banyak pemain berusaha untuk mendapatkan jackpot https://bonaslot.site/# Permainan slot mudah dipahami dan menyenangkan
Permainan slot mudah dipahami dan menyenangkan https://preman69.tech/# Kasino mendukung permainan bertanggung jawab
http://slot88.company/# Slot klasik tetap menjadi favorit banyak orang
Kasino memastikan keamanan para pemain dengan baik https://garuda888.top/# Mesin slot dapat dimainkan dalam berbagai bahasa
https://viagraauonline.com
Banyak kasino memiliki promosi untuk slot https://garuda888.top/# Slot menawarkan kesenangan yang mudah diakses
Сауна очищает организм https://sauna-broadway.ru выводя токсины через пот, укрепляет иммунитет благодаря перепадам температуры, снимает стресс, расслабляя мышцы и улучшая кровообращение. Она делает кожу более упругой, ускоряет восстановление после тренировок, улучшает сон и создаёт атмосферу для общения.
Jackpot progresif menarik banyak pemain: slot88 – slot 88