踩到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"); }
педагогический диплом купить
купить готовый диплом
Slot dengan tema budaya lokal menarik perhatian http://slot88.company/# п»їKasino di Indonesia sangat populer di kalangan wisatawan
Kasino di Jakarta memiliki berbagai pilihan permainan: bonaslot – bonaslot
Though the Kuznets curve described the event of inequality well on the time of its publication, there’s now a rising variety of important voices questioning the link between inequality and development.
купить диплом москва
купить диплом об окончании пту
http://garuda888.top/# Slot menawarkan kesenangan yang mudah diakses
garuda888.top garuda888 Mesin slot menawarkan pengalaman bermain yang cepat
https://slot88.company/# Kasino menyediakan layanan pelanggan yang baik
Banyak kasino menawarkan permainan langsung yang seru http://bonaslot.site/# Pemain harus memahami aturan masing-masing mesin
Slot menawarkan kesenangan yang mudah diakses http://preman69.tech/# п»їKasino di Indonesia sangat populer di kalangan wisatawan
http://slotdemo.auction/# Kasino sering memberikan hadiah untuk pemain setia
slotdemo slot demo rupiah Pemain harus menetapkan batas saat bermain
диплом гознак купить
http://slotdemo.auction/# Banyak pemain berusaha untuk mendapatkan jackpot
Slot dengan tema film terkenal menarik banyak perhatian http://garuda888.top/# Permainan slot bisa dimainkan dengan berbagai taruhan
Kasino di Indonesia menyediakan hiburan yang beragam: preman69.tech – preman69
https://slot88.company/# Slot menawarkan berbagai jenis permainan bonus
Kasino selalu memperbarui mesin slotnya: garuda888 – garuda888.top
Kasino menawarkan pengalaman bermain yang seru https://bonaslot.site/# Mesin slot menawarkan pengalaman bermain yang cepat
Mesin slot digital semakin banyak diminati http://preman69.tech/# Slot dengan tema budaya lokal menarik perhatian
Bermain slot bisa menjadi pengalaman sosial: preman69.tech – preman69
Banyak pemain mencari mesin dengan RTP tinggi: preman69 slot – preman69 slot
http://slotdemo.auction/# Kasino sering mengadakan turnamen slot menarik
https://garuda888.top/# Slot dengan grafis 3D sangat mengesankan
Banyak pemain menikmati jackpot harian di slot http://garuda888.top/# Slot klasik tetap menjadi favorit banyak orang
Kasino memastikan keamanan para pemain dengan baik http://garuda888.top/# Slot dengan tema film terkenal menarik banyak perhatian
Carrie Underwood slated to perform at Trump’s inauguration
kraken войти
Country music star Carrie Underwood is slated to perform “America the Beautiful” at President-elect Donald Trump’s inauguration, according to a copy of the program obtained by CNN and confirmed by a spokesperson for the inaugural committee.
“I love our country and am honored to have been asked to sing at the Inauguration and to be a small part of this historic event,” Underwood said in a statement to CNN. “I am humbled to answer the call at a time when we must all come together in the spirit of unity and looking to the future.”
The presidential oath of office will be administered by Supreme Court Chief Justice John Roberts with Justice Brett Kavanaugh expected to administer the oath of office to Vice President-elect JD Vance.
Trump’s inauguration as the 47th president of the United States will take place on January 20 at the US Capitol.
Underwood is a big get for Trump’s inauguration, considering Hollywood’s Trump blackout over the course of his political career.
In his first term and throughout the past three elections, Trump has struggled to garner support from major Hollywood stars. At the Republican National Convention last year, the two biggest stars onstage with Trump were musician Kid Rock and retired WWE wrestler Hulk Hogan – a far cry from a superstar at the height of their career, like Underwood.
The Grammy-winning artist is as high-profile as you can get in country music, not only with numerous platinum hits, but also with public-facing, mainstream business associations. Underwood is the face of Sunday Night Football and is set to make her debut this March as a judge on ABC’s “American Idol” – the singing competition show that catapulted her to fame when she won in 2005.
While many NFL fans will likely applaud Underwood for singing at the inauguration, any time a celebrity aligns themselves with Trump, they run the risk of alienating left-leaning fans and Hollywood allies.
Underwood has kept her politics under wraps over the course of her career. In her statement, she did not mention Trump by name and kept her focus on unifying the country – still, Underwood’s decision to publicly align with Trump is a big statement for any star, particularly one as private as the singer.
Historically, Hollywood has always been closely associated with the Democratic Party, but country stars have always been an outlier, leaning more conservative. In recent years, as new singers join the genre, country music has gotten to be more progressive. This past election cycle, country stars like Mickey Guyton and Maren Morris stood with Vice President Kamala Harris.
https://slotdemo.auction/# Banyak pemain mencari mesin dengan RTP tinggi