Loading...

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

Temperature: 0 °C

Mark ChangMark Chang
在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>

參考連結網址


以上紀錄

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

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

parse_url解析 URL

parse_url解析 URL

parseurl() 用來解析 URL 的函數,適用於(PHP , PHP , PHP...

分享 喝咖啡會致癌?!加州法院裁定:咖啡供應商應標明罹癌警語-風傳媒

分享 喝咖啡會致癌?!加州法院裁定:咖啡供應商應標明罹癌警語-風傳媒

好可怕啊~快先喝一杯壓壓驚。...

分享 區塊鏈50

分享 區塊鏈50

區塊鏈...

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