Day # 76: Screenshot



Using canvas along with Javascript allows you to obtain a screenshot. The key here is to select the section of the document that you want to capture:


<button id="capture-btn" title="Get Screenshot!">

       <i class="fa-solid fa-camera-retro"></i>

</button>


canvas2html was used in order to capture the elements within the specified container:

captureBtn.addEventListener("click", async() => {

    downloadBtn.classList.remove("hide")

    const canvas = await html2canvas(container)

    const imageURL = canvas.toDataURL()

    previewContainer.innerHTML = `<img src="${imageURL}" id="image">`

})

 

Comments

Popular posts from this blog

Day # 35: Flip Book

Day # 1: Homepage w/Introduction

Day # 8: Inspiration