Loading...

使用html2canvas截圖將背景顏色更改為白色

Temperature: 0 °C

Mark ChangMark Chang
author_tools

在Javascript裡,我們可以使用html2canvas來將網頁畫面的某個區塊截圖下來存檔。

運用方式如下:
HTML

<div id="container">
Hello world!
</div>

JavaScript
  $('html, body').scrollTop(0);
   html2canvas(document.getElementById('container')).then(function(canvas) {
           var a = document.createElement('a');
            a.href = canvas.toDataURL("image/jpeg").replace("image/jpeg", "image/octet-stream");
            a.download = 'image.jpg';
            a.click();
   });

若要將擷取下來的畫面讓背景呈現白色只需要將HTML修改如下:
<div id="container" style="background:#FFF">
Hello world!
</div>

參考Url link

使用html2canvas截圖將背景顏色更改為白色
以上紀錄

 

https://innstory.com/story-使用html2canvas截圖將背景顏色更改為白色-2346
javascript

Prev
 發現茄十二星瓢蟲

Next
分享_Googlenew服務新增Adobe瀏覽器中就可轉PDF檔 

About the Author

Mark Chang

離不開電腦的宅男

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

分享 【東京奧運開幕典禮】超級變變變!超創意呈現1964年的50個靜態項目圖標

分享 【東京奧運開幕典禮】超...

我從小就是超級變變變的迷,這次的東京奧運真的好有創意啊~ 最後如果亮燈了~阿欽出來就更讚了

分享 首度載人試飛成功!日本新創SkyDrive拚2023年造出飛天計程車、30年後人人可搭|數位時代

分享 首度載人試飛成功!日本...

歡迎來到小叮噹的時代。 只是還要年,看來我是享受不到這樣的服務了。

分享 Google.new服務新增Adobe瀏覽器中就可轉PDF檔

分享 Google.new服...

話說,Google的服務真的是包山包海。 根本就是IT界的Eleven。

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format