// Get the element you want to capture as a screenshot
const targetElement = document.getElementById('elementId'); // Replace 'elementId' with the ID of the element you want to capture
// Create a temporary canvas
const canvas = document.createElement('canvas');
canvas.width = targetElement.offsetWidth;
canvas.height = targetElement.offsetHeight;
// Capture the element's image onto the canvas
const context = canvas.getContext('2d');
context.drawWindow(
window,
targetElement.getBoundingClientRect().left,
targetElement.getBoundingClientRect().top,
targetElement.offsetWidth,
targetElement.offsetHeight,
'rgb(255,255,255)'
);
// Create a link to download the screenshot
const screenshotImage = canvas.toDataURL('image/png');
const downloadLink = document.createElement('a');
downloadLink.href = screenshotImage;
downloadLink.download = 'screenshot.png';
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 108 guests