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

html2canvas cannot open an arbitrary external URL and photograph it. It runs inside a page you control, reads the DOM and styles that browser security allows it to read, and reconstructs that content on a canvas. If “external website” means a page loaded in another tab, html2canvas has no access to it. If it means an element in your page, a same-origin iframe, or remote images used by your page, the result depends on which origin owns each resource.

This distinction determines the correct solution. You can capture your own DOM, capture a same-origin iframe, and often load remote images with CORS. You cannot use html2canvas to read the DOM of a cross-origin iframe or bypass a site’s content-security rules. For a true URL-to-screenshot operation, use a browser-based screenshot service instead of trying to turn html2canvas into a remote crawler.

What html2canvas actually does

html2canvas is a client-side JavaScript library. It traverses an element’s DOM tree, examines supported CSS and resources, then draws an approximation of the rendered result into an HTML canvas. It does not capture the browser’s composited surface the way an operating-system screenshot or headless browser does. Effects and CSS features that the library does not support may be absent or look different.

The library’s own description is that it takes “screenshots” of webpages or parts of them directly in the user’s browser. The quotation marks matter: the output is a reconstruction from readable page data, not a pixel-perfect photograph of everything the browser displayed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Tworider Screen Repair Kit & Window Screen Replacement Kit with Spline Roller Tool, Spline Removal Hook, Screen Cutter - Easy to Use 5-in-1 Tool for Screen Door Repair, Windows, Patio & Sliding Doors
  • 🌟 All-in-One Screen Solution: Essential for seamless window screen replacement & repairs. This versatile screen repair kit Perfect for DIY screen spline insertion, frame rolling, and mesh tightening – your go-to tool for screen for windows projects.
  • 🔷 Dual Roller Innovation: Features convex (round) & concave (grooved) steel rollers. The concave roller prevents delicate screen tearing during spline rolling, while the convex wheel ensures tight sealing. Ultimate precision for window screen tool tasks.
  • ❖ Ergonomic Wooden Handle: Solid hardwood handle delivers superior comfort during prolonged screen roll installation. Non-slip grip reduces hand fatigue when replacing window screens. Durable steel bearings ensure smooth roller rotation – ideal for screen door repair marathons.
  • 🔧Spline Tool + Screen Roller Tool: Offers three roller diameter options for selection. When replacing window screens, choose the corresponding roller based on the Spline specifications to completely eliminate tool size mismatch issues.
  • 💎 Pro-Grade Durability: Carbon-steel rollers withstand aggressive spline rolling without deformation. your lifetime screen repair tool investment.

Four meanings of “external website”

  • An element in your current page: html2canvas can normally render it, subject to supported CSS and resource access.
  • A same-origin iframe: the parent page can access the iframe document, so rendering its contents is possible when the document is otherwise readable.
  • A cross-origin iframe: the parent page cannot inspect its document. The browser’s same-origin policy blocks the DOM access html2canvas would need.
  • Remote images in your page: images are separate resources. They may load for display but still prevent pixel export unless the image response grants CORS access or the image is fetched through a suitable proxy.

Neither useCORS nor proxy grants permission to inspect a different site’s HTML. They address resource loading, especially images, not arbitrary cross-origin DOM access.

Capture content in your own page

Install html2canvas through your normal package workflow or load the version used by your application. The following example captures an element and downloads a PNG.

import html2canvas from 'html2canvas';

const element = document.querySelector('#invoice');
if (!element) throw new Error('Missing #invoice element');

const canvas = await html2canvas(element);
canvas.toBlob((blob) => {
  if (!blob) throw new Error('Canvas could not be encoded');
  const link = document.createElement('a');
  link.href = URL.createObjectURL(blob);
  link.download = 'invoice.png';
  link.click();
  URL.revokeObjectURL(link.href);
}, 'image/png');

If you use a script tag rather than a module, call html2canvas(document.querySelector('#invoice')) after the library and target element have loaded. Wait for fonts, images and application data before starting the capture; otherwise the reconstruction may contain fallback fonts or empty regions.

Capture a region or the full scrollable element

The documented examples support x, y, width and height for a region, and scale for controlling output density.

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.
const panel = document.querySelector('#long-panel');
const canvas = await html2canvas(panel, {
  x: 0,
  y: 0,
  width: panel.scrollWidth,
  height: panel.scrollHeight,
  windowWidth: panel.scrollWidth,
  windowHeight: panel.scrollHeight,
  scale: window.devicePixelRatio
});

const png = await new Promise((resolve, reject) => {
  canvas.toBlob(blob => blob ? resolve(blob) : reject(new Error('No blob')), 'image/png');
});

scale changes the number of canvas pixels used for the reconstruction. A higher value can improve text sharpness on high-density displays, but it also increases memory use and the chance of hitting a browser canvas-size limit. Start with the default or device-pixel ratio and reduce it if large captures fail.

Rank #2
King&Charles Screen Roller Tool 2in1-Bearing Roller+Hook to Replace Mesh
  • ⭐【QUALITY MATERIALS】- Solid wood handle + double carbon steel bearing metal wheels, heavy beech wood handles are hard and crack-free, thickened and enlarged metal convex and concave double wheels, each of them is finely crafted and durable, suitable for the replacement of aluminum alloy plastic steel doors and windows of any specification.
  • ⭐【SCREEN TOOLS SET】- The screen rolling tool has two different wheels, cams and recessed rollers, which can help you get the job done better and faster. Screen roller is compact and easy to carry,which is can solve your problem well. Every one is meticulously crafted and durable, A good helper for replacing screens at home.
  • ⭐【EASY TO USE】- Installing a screen with a screen rolling tool makes the job much easier. This essential tool is comfortable in the hand and the wheels turn smoothly to roll the screen and spline into the frame. It’s extremely economical and adds great value to big and small screen repair jobs.
  • ⭐【ERGONOMIC HANDLE】- The wood handle has ergonomic design, it is easy to hold. wooden handle and steel convex and concave roller wheels,the steel wheels of our screen rolling tool is smooth The hooks are sharp and the aged battens can be hooked out.
  • ⭐【CONVEX & CONCAVE 】– The combination screen rolling tool has a 1-5/16" x 3/32" convex (round edge) steel roller at one end and a 1-5/16" x 3/32" concave (grooved edge) steel roller at the opposite end.

Remote images: CORS versus a proxy

Remote images are the most common reason a capture looks incomplete or cannot be exported. A browser may display an image from another origin while still forbidding JavaScript from reading its pixels. Once an image loaded without CORS approval is drawn into a canvas, the canvas becomes tainted. Calls such as getImageData(), toDataURL() and toBlob() can then throw a SecurityError.

Try CORS only when the image server supports it

const canvas = await html2canvas(document.querySelector('#gallery'), {
  useCORS: true
});
const dataUrl = canvas.toDataURL('image/png');

The documented default for useCORS is false. Setting it to true tells html2canvas to attempt a CORS-enabled image request; it does not add an Access-Control-Allow-Origin header. The image host must return an appropriate header, and the request must use a mode and credentials policy compatible with that response. Inspect the image request in your browser’s Network panel to verify the response headers.

Use a proxy for image resources

When the image host does not grant CORS access, html2canvas documents a proxy option. The proxy fetches the resource server-side and returns it in a way your page can load. Operate the proxy yourself or use one you trust, validate allowed destinations, limit response sizes, and prevent it from becoming an open server-side request forgery relay.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const canvas = await html2canvas(document.querySelector('#gallery'), {
  proxy: 'https://your.example/proxy'
});

The documented default for proxy is null. A proxy can solve an image-loading problem; it cannot unlock the DOM inside a cross-origin iframe.

Why allowTaint: true is not an export fix

allowTaint defaults to false. Enabling it may allow cross-origin images to be drawn even though they taint the canvas, but browser security still prevents reading or exporting pixels from that tainted canvas. If your goal is a PNG, JPEG, WebP or pixel analysis, this is not a substitute for CORS or a proxy.

Rank #3
King&Charles Versatile Screen Roller Tool, 3pcs Different Roller+Hook+Trim
  • --- 𝐏𝐀𝐓𝐄𝐍𝐓 𝐀𝐏𝐏𝐋𝐈𝐄𝐃 𝐅𝐎𝐑---
  • 🏡【𝐊𝐢𝐧𝐠&𝐂𝐡𝐚𝐫𝐥𝐞𝐬 𝐑&𝐃 𝐈𝐧𝐭𝐞𝐧𝐭𝐢𝐨𝐧】Versatile Screen Tool - combines the core functions of multi-size roller, hidden hooks, and replaceable blades, and designed this multifunctional screen tool. It solves the problems of traditional screen installation tools with single functions, lack of safety and adaptability. It truly realizes multiple uses of one tool, making screen replacement time-saving, labor-saving, and worry-free. One-time purchase can meet your installation or replacement needs.
  • 🏡【𝟑 𝐒𝐢𝐳𝐞𝐬 𝐈𝐧𝐭𝐞𝐫𝐜𝐡𝐚𝐧𝐠𝐞𝐚𝐛𝐥𝐞 𝐑𝐨𝐥𝐥𝐞𝐫𝐬】Flexible Adaptation - In view of the differences in thickness of different window splines, we gift the roller into three specifications: Convex 0.13", Concave 0.13", and Concave 0.18", ensuring perfect matching with the mainstream rubber strip sizes on the market. Feature①: The roller is made of high-hardness plastic, which is strong and durable while avoiding the risk of traditional metal rollers scratching the screen mesh. Feature②: Metal bearing design - smoother rotation, even pressure without deviation. TIPS: you can use the provided Allen wrench to quickly disassemble and replace them.
  • 🏡【𝐁𝐥𝐚𝐝𝐞 𝐅𝐮𝐧𝐜𝐭𝐢𝐨𝐧-𝐑𝐞𝐭𝐫𝐚𝐜𝐭𝐚𝐛𝐥𝐞&𝐒𝐭𝐨𝐫𝐚𝐠𝐞&𝐑𝐞𝐩𝐥𝐚𝐜𝐞𝐚𝐛𝐥𝐞】①Retractable-When in use, just hold button, blade will slow rollout, convenient trimming and cutting. Blade can be retracted to prevent Accident scratches. ②Blade has double locking device: it automatically locks to prevent retraction during work and is completely closed to prevent accidental touch when retracted. Ansure your safety. ③Replaceable - A separate button is provided for changing the blades. ④Blade is made of steel-sharp, durable and won't rust. ⑤Storage-Handle has built-in blade storage design to place complimentary blade.Extra equipped 2xreplacement blades- increase service life of tool.
  • 🏡【𝐇𝐢𝐝𝐞𝐚𝐛𝐥𝐞 𝐑𝐞𝐦𝐨𝐯𝐚𝐥 𝐇𝐨𝐨𝐤】The hooks are sharp and can hook out the aged spline. The removal hook can be stored and hidden in the handle slot box. OPEN the box cover, take out the hook and insert it into the groove for use. can RETRACT after use to prevent the hook tip from scratching clothes or tool boxes. Hook made of Stainless steel material won't rust.

Can html2canvas capture a cross-origin iframe?

No. A parent document cannot read a cross-origin iframe’s contentDocument under the same-origin policy. html2canvas must inspect the document tree to reconstruct it, so it cannot capture the iframe’s internal page from the parent.

Practical options are limited:

  • Ask the embedded site to provide a same-origin integration or an export endpoint.
  • Run capture code inside the framed page itself, if you control that page and its policies permit it.
  • Use a real browser screenshot system that navigates to the URL as a browser, rather than trying to read the iframe from your page.

Changing iframe attributes, adding allow permissions, or enabling html2canvas options does not remove the origin boundary.

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

Complete capture checklist

  1. Classify the target. Decide whether it is a local DOM subtree, same-origin iframe, cross-origin iframe, or local content containing remote images.
  2. Wait for stable content. Capture after application data, web fonts and images have finished loading. For lazy content, scroll or otherwise trigger the loading behavior before capture.
  3. Check image responses. Confirm that remote image responses include suitable CORS headers if you plan to export the canvas.
  4. Choose options deliberately. Use useCORS: true for a CORS-capable image host; use proxy for resources served through a proxy; leave allowTaint disabled when exportability matters.
  5. Control dimensions. Set region dimensions explicitly for long elements, and reduce scale or split the capture if the canvas becomes too large.
  6. Export only after success. Check that a canvas was returned and handle a null blob or security exception instead of silently downloading an empty file.

Troubleshooting common failures

“Why aren’t my images rendered?”

First determine whether the image request failed, was blocked by a content policy, or loaded without CORS. Look at the request status and response headers. If the host supports CORS, retry with useCORS: true. If it does not, route the image through a controlled proxy or use a replacement asset you are authorized to serve. Do not expect allowTaint to make the resulting pixels exportable.

toDataURL() or toBlob() throws a security error

An unapproved cross-origin resource probably tainted the canvas. Find every remote image, canvas, SVG image or other resource drawn into the target. Fix each resource’s CORS response or proxy it before rendering. Removing only the visibly missing image may not be enough if another asset remains tainted.

The canvas is empty or cuts off halfway

Check that the selector points to a rendered element and that capture runs after layout and data updates. For a long element, use its scroll dimensions and matching windowWidth and windowHeight. If the result is still clipped, reduce the capture area or scale. Browsers impose canvas-size and memory limits, and those limits vary by browser and device.

CSS looks different from the page

That is expected when a CSS property or browser effect is outside html2canvas’s supported rendering model. Simplify the capture stylesheet, replace unsupported effects with explicit backgrounds or images, and compare the output in the browsers you support. A browser screenshot service is a better fit when exact compositing, animations, plugins or browser chrome matters.

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

The iframe appears as a blank box

Determine its origin. Same-origin content may be capturable after it has loaded; cross-origin content is not readable by the parent and cannot be fixed with html2canvas settings. Capture from code hosted by the iframe’s origin or navigate a browser automation system directly to the target URL.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability and security considerations

  • Memory: canvas memory grows with pixel dimensions and scale. Capture smaller regions, lower scale, or separate a very long page into sections.
  • Timing: use application-level readiness signals where possible instead of an arbitrary short delay. Images, fonts and asynchronous components can finish at different times.
  • Repeatability: disable animations during capture, freeze changing data, and use a consistent viewport and device-pixel ratio when comparing images.
  • Proxy safety: allow-list destinations, enforce HTTPS where appropriate, cap response size and time, and avoid forwarding user credentials to arbitrary hosts.
  • Browser limits: unsupported CSS, content policies, canvas limits and device resources can all affect output independently of iframe access.

Or skip the browser setup

If your requirement is “give me an image or PDF of this URL,” a URL screenshot API is simpler than embedding html2canvas in a page and dealing with cross-origin resources. ScreenshotNeo is the first alternative to try because it removes consent banners, newsletter popups and chat widgets before capture, bills only clean shots, and has a $5 paid plan for 3,000 shots.

One GET request returns a PNG, JPEG, WebP or PDF. The response identifies outcomes with X-Page-Verdict and X-Billed headers; bot checks, blank pages, timeouts, failed loads and cache hits cost nothing.

cURL

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)
r.raise_for_status()
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}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const body = Buffer.from(await res.arrayBuffer());
await import('node:fs/promises').then(fs => fs.writeFile('shot.webp', body));

See the ScreenshotNeo documentation for request options. It supports full-page captures with lazy images, CSS-selector element capture, dark mode, device presets and custom viewports, retina scale, PDFs with paper size, margins, orientation and page ranges, custom CSS and JavaScript, clicks, selector waits, delays, network-idle waits, ad and tracker blocking, custom headers, cookies, user agents, authorization, timezone and geolocation, transparent backgrounds, resizing, configurable caching, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API and an OpenAPI specification. Existing parameter names used by other screenshot APIs also work to ease migration.

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

ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info and capture_pdf for Claude, Cursor and other MCP clients. Every plan includes every feature: 1,000 shots per month are free with no card; paid plans start at $5 for 3,000. Create a free ScreenshotNeo account to try the URL-based approach.

Best Value
Hasron Window Screen Removal Tool - 9-Inch, Scratch-Free, Dual-End, Orange
  • WINDOW SCREEN REMOVAL TOOL: Designed to easily engage, lift, and remove window screens without damaging frames or mesh.
  • Durable Nylon Construction – Made from high-strength, impact-resistant nylon that's tough enough to handle repeated use yet gentle on delicate surfaces, won't rust or corrode like metal tools.
  • DUAL-END DESIGN: Features a forked end to engage and lift screen edges and a flat pry tip on the opposite end for versatile use.
  • HIGH-VISIBILITY COLOR: Bright orange construction makes this tool easy to spot and prevents it from being misplaced on the job site.
  • DIY-FRIENDLY: The ideal tool for homeowners and professionals tackling window screen repair, replacement, or seasonal removal tasks.

Choosing the right method

Requirement Best fit Reason
Your own component or page region html2canvas Runs in the page and can capture a DOM subtree without a server.
Same-origin iframe html2canvas, after the iframe loads The parent can inspect the iframe document.
Remote images in an otherwise local page html2canvas with CORS or a resource proxy Image access depends on response headers; the proxy handles resources, not DOM.
Cross-origin iframe or arbitrary URL Browser screenshot service The parent page cannot read the remote DOM.
PDF, bulk URLs, authenticated pages or repeatable server jobs Screenshot API Server-side navigation and job controls avoid a user’s browser context.

Frequently Asked Questions

Does html2canvas take a screenshot of the entire browser window?

No. It renders a selected DOM element and its readable resources into a canvas. Browser chrome and content that the page cannot inspect are outside its scope.

Can I fix a cross-origin iframe by setting document.domain?

Do not rely on that approach. Both participating pages would need compatible origin handling, and modern browser policies and deployment constraints make it unsuitable for arbitrary third-party sites.

Is a CORS header set in JavaScript?

No. The server hosting the image must send the appropriate Access-Control-Allow-Origin response header. Frontend code can request CORS but cannot grant itself permission.

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

Why does a screenshot API produce a different result from html2canvas?

html2canvas reconstructs a DOM subtree in the current browser. A screenshot API navigates a browser to a URL and captures its rendered page, so viewport, timing, cookies, scripts and resource handling can differ.

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.