DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
html2canvas

How to Add a Full-Page Screenshot Button to a Website

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a button inside a website you control, use a DOM-to-image library such as html2canvas, then download the generated canvas as an image. This approach runs in the visitor’s browser and can capture the document rather than only the visible viewport. It reconstructs the page from readable DOM and CSS, however; it is not a pixel-for-pixel photograph of the browser’s rendered framebuffer. Cross-origin images, cross-origin iframes and unsupported CSS can be missing or inaccurate.

The code below creates a practical full-page PNG button, explains its limits, and shows when a browser extension, Screen Capture API or hosted renderer is a better fit.

Decide where the screenshot button should live

“Full-page screenshot” can describe several different products. Choose the capture surface before writing code:

Need Suitable route Important limitation
A control embedded in your site Client-side DOM reconstruction with html2canvas or a similar library Only readable DOM, assets and supported CSS are rendered; output is not guaranteed to match browser pixels.
A user-selected tab, window or monitor Screen Capture API (getDisplayMedia()) The browser asks the visitor to confirm and select a source. It is not a silent document-export API.
A browser-toolbar button or automated browser capture Extension APIs, potentially Chrome debugger/CDP facilities Requires a separate extension architecture, permissions and possibly enterprise approval.
Your own occasional screenshots Firefox’s built-in screenshot interface or developer tools This helps the person operating the browser, not visitors to your website.

If the requirement is “let a visitor save this page from a button,” start with the first row. If you need the exact pixels produced by a browser engine, move capture to an extension or a controlled server-side browser instead of promising that a DOM renderer is pixel-perfect.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

Build the in-page button with html2canvas

1. Add the library and controls

Load html2canvas and provide a real button with an accessible label. The example targets the document’s main content so the button itself and unrelated site chrome do not appear in the export.

<button id="save-full-page" type="button">Save full-page screenshot</button>
<main id="capture">
  <!-- The page content to export -->
</main>
<script src="https://cdn.jsdelivr.net/npm/html2canvas@latest/dist/html2canvas.min.js"></script>

For a production site, pin a reviewed library version rather than relying on @latest, and apply your normal content-security-policy and dependency review.

2. Capture the complete target and download a PNG

const button = document.getElementById('save-full-page');
const target = document.getElementById('capture');

button.addEventListener('click', async () => {
  const oldLabel = button.textContent;
  button.disabled = true;
  button.textContent = 'Preparing screenshot…';

  try {
    // Let layout settle before html2canvas reads the DOM.
    await new Promise(requestAnimationFrame);

    const canvas = await html2canvas(target, {
      backgroundColor: '#ffffff',
      useCORS: true,
      allowTaint: false,
      logging: false,
      windowWidth: document.documentElement.scrollWidth,
      windowHeight: document.documentElement.scrollHeight,
      scrollX: 0,
      scrollY: -window.scrollY
    });

    const link = document.createElement('a');
    link.download = 'page-screenshot.png';
    link.href = canvas.toDataURL('image/png');
    link.click();
  } catch (error) {
    console.error(error);
    alert('The page could not be rendered as an image. Check cross-origin assets and try again.');
  } finally {
    button.disabled = false;
    button.textContent = oldLabel;
  }
});

The negative scrollY helps prevent the visitor’s current scroll position from shifting fixed-position content during the render. The exact result depends on the target page and the library’s supported CSS properties. Do not describe this as a capture of the browser’s actual framebuffer.

3. Capture the entire document instead of a content wrapper

If you truly want everything on the page, pass document.documentElement or document.body as the target. A dedicated wrapper is usually safer because it excludes the save button, cookie controls and navigation that you may not want in the image.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const target = document.documentElement;
const canvas = await html2canvas(target, {
  width: document.documentElement.scrollWidth,
  height: document.documentElement.scrollHeight,
  windowWidth: document.documentElement.scrollWidth,
  windowHeight: document.documentElement.scrollHeight,
  scrollX: 0,
  scrollY: -window.scrollY
});

Very long documents create large canvases and can consume substantial memory. There is no universal safe maximum: test the longest pages and lowest-memory devices you support, and offer section capture or a PDF alternative when a single bitmap becomes impractical.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

4. Improve consistency before rendering

  • Wait for fonts and important images: await document.fonts.ready and, where appropriate, await image loads.
  • Pause CSS animations and blinking cursors while capture runs; otherwise the output depends on timing.
  • Expand collapsed sections if “full page” means all available content, not merely what is currently visible.
  • Use a temporary class to hide the button, sticky headers, video controls and other capture-only elements.
  • For lazy-loaded images, scroll through the page first or provide an explicit “load all content” state. A renderer cannot draw pixels that have not loaded.
async function waitForImages(root) {
  const images = [...root.querySelectorAll('img')];
  await Promise.all(images.map(img => {
    if (img.complete) return Promise.resolve();
    return new Promise(resolve => {
      img.addEventListener('load', resolve, { once: true });
      img.addEventListener('error', resolve, { once: true });
    });
  }));
}

await document.fonts.ready;
await waitForImages(target);

Understand html2canvas’s fidelity and security boundaries

It reconstructs; it does not photograph

html2canvas traverses the DOM and draws a representation from properties it understands. CSS that the library does not support can render incorrectly or disappear. Browser-specific painting details, compositing and some filters therefore may differ from what the visitor sees.

Cross-origin images can taint the canvas

Images generally need to be same-origin or delivered with appropriate cross-origin headers. A cross-origin image without permission can taint the canvas; reading it with toDataURL() then fails for security reasons. useCORS: true requests CORS-enabled loading, but it cannot grant permission that the image server does not provide. A proxy under your control is another documented approach, subject to the image owner’s terms and your own security review.

Cross-origin iframes are not readable

Same-origin iframes can be recursively rendered. A frame from another origin cannot be accessed through its contentDocument, so its contents cannot be reconstructed by page JavaScript. You may need cooperation from the framed application, a server-side capture, or an alternative export.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Protect sensitive content

The generated image can contain private data already present in the DOM. Do not upload it automatically without consent. If you add a server upload, authenticate the request, limit file size and lifetime, and treat the image as sensitive user content.

Make the download robust

canvas.toDataURL() is simple but creates a data URL in memory. For larger captures, use a Blob and an object URL:

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.
canvas.toBlob(blob => {
  if (!blob) throw new Error('Canvas export failed');
  const url = URL.createObjectURL(blob);
  const link = document.createElement('a');
  link.download = 'page-screenshot.png';
  link.href = url;
  link.click();
  URL.revokeObjectURL(url);
}, 'image/png');

PNG preserves sharp text and transparency; JPEG is smaller but introduces lossy compression and requires a background color; WebP can be a useful modern compromise where your download requirements permit it. A retina-style scale improves detail but multiplies memory use, so expose it only after testing.

Why the Screen Capture API is usually the wrong button

getDisplayMedia() captures a display surface selected by the visitor. The browser presents a permission prompt and source picker before returning a media stream. It is appropriate for screen sharing or a user-authorized recording workflow, not for silently saving the complete document with one click. If your page is embedded and policy restricts display capture, the response may also require a display-capture Permissions Policy header or iframe allow attribute.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const stream = await navigator.mediaDevices.getDisplayMedia({ video: true });
video.srcObject = stream;
stream.getVideoTracks()[0].addEventListener('ended', () => {
  video.srcObject = null;
});

This does not solve stitching a long page into one image and should not be presented as an invisible full-page capture mechanism.

When an extension or browser tool is the better design

An extension can operate at browser level, but it is not code you can simply paste into a website. Chrome’s debugger API requires the debugger manifest permission, and enterprise policy can deny attachment or screenshot capture. Firefox documents tabs.captureVisibleTab() for the active tab’s visible area; the documented material does not establish that this API alone captures an entire long document.

For personal use, Firefox offers a screenshot interface with “Save full page,” an optional Developer Tools screenshot button and the Web Console command :screenshot --fullpage. Those controls are useful when you do not own the site and do not need to ship a visitor-facing feature.

Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

Test checklist before shipping

  • Capture short, long and extremely long pages at supported viewport widths.
  • Test Chromium-based browsers, Firefox and Safari; treat this as coverage, not a promise that every CSS property matches.
  • Include same-origin images, CORS-enabled images, blocked images and both same-origin and cross-origin iframes.
  • Check web fonts, sticky and fixed elements, animations, videos, gradients, filters, transforms and open shadow-DOM components.
  • Test logged-in pages and redact or exclude secrets before any upload.
  • Verify that canceling, a tainted canvas, a failed image and a memory exception restore the button state.
  • Measure user-perceived delay and show progress or a busy label for long renders.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common failures

The image is blank or only partly rendered

Confirm that the target has dimensions and visible content, wait for fonts and images, and capture after layout settles. Check the browser console for cross-origin or canvas-security errors.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Images are missing

Serve them from the same origin or configure the image server for CORS, then use useCORS: true. A client-side option cannot override a server that omits permission headers.

An iframe is empty

Cross-origin frame contents are blocked by browser security. Capture the frame in its own context, obtain cooperation from its owner, or use a controlled remote browser.

Fixed headers appear repeatedly or cover content

Hide them with a temporary capture class, adjust the scroll options, or capture a content wrapper that excludes site chrome.

The browser becomes slow or crashes

Reduce scale, capture a smaller region, split the document into sections, or move rendering to a server-side browser. Large bitmaps consume memory faster than their compressed download size suggests.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

The result does not match what the user sees

That is an inherent DOM-reconstruction limitation. Audit unsupported CSS and timing-sensitive content; if exact browser pixels are mandatory, choose an extension or remote browser workflow instead.

Or skip the browser setup

For arbitrary URLs, server-side rendering, scheduled jobs or AI-driven workflows, ScreenshotNeo provides a website screenshot API and MCP server. A GET request returns PNG, JPEG, WebP or PDF, while options cover full-page capture, lazy-image loading, CSS-selector elements, dark mode, device presets, retina scale, custom CSS and JavaScript, clicks, waits, blocked resources, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, caching, signed links, asynchronous webhooks, bulk capture and usage reporting.

Example using cURL (see the ScreenshotNeo documentation):

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Cookie banners, newsletter popups and chat widgets are removed before the shot. Bot checks, blank pages, failed loads and cache hits are not billed, and response headers identify the page verdict and billing result. Its MCP server lets Claude, Cursor and other MCP clients call screenshot, page-info and PDF tools. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Can a website take a screenshot without asking the visitor for permission?

A DOM renderer such as html2canvas can render page content without a display-sharing prompt, subject to its DOM, CSS and cross-origin limits. The Screen Capture API always requires the browser’s confirmation and source selection.

Does html2canvas capture content inside every iframe?

Only same-origin iframe documents can be read and recursively rendered. Cross-origin iframe content is blocked by browser security rules.

Should I use PNG or JPEG?

PNG is usually best for text and interface screenshots. JPEG can reduce file size when a solid background and some compression loss are acceptable.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.