Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallWith html2canvas, the shortest way to exclude a frame is to mark it with data-html2canvas-ignore:
<iframe src='https://embed.example/' data-html2canvas-ignore></iframe>
If you cannot edit the markup, pass an ignoreElements predicate. For rules that should affect only the temporary rendering copy, remove the frame in onclone. These are html2canvas APIs, not universal options for browser automation libraries.
Choose the exclusion method
All three approaches are documented by html2canvas. Pick according to whether you control the markup, how many frames should be omitted, and whether the original document must remain untouched.
| Method | Best for | What it changes |
|---|---|---|
data-html2canvas-ignore |
One or a few known iframes whose HTML you can edit | Marks those elements to be skipped during rendering |
ignoreElements |
All iframes, or a reusable selector-like rule | Returns true for elements html2canvas should ignore |
onclone |
Clone-only edits, such as removing or replacing frames for one capture | Mutates the cloned document used for rendering, not the live page |
The html2canvas options reference documents the attribute, ignoreElements, and onclone. The official examples show the ignore attribute in use.
#1 Best Overall
Exclude one iframe with the data attribute
Use this when the iframe is part of markup you own. The attribute has no value; its presence is enough.
<section id='capture'>
<h1>Report</h1>
<iframe src='https://embed.example/' data-html2canvas-ignore></iframe>
<p>This text remains in the rendered image.</p>
</section>
<button id='save'>Save screenshot</button>
<script type='module'>
import html2canvas from 'html2canvas';
document.querySelector('#save').addEventListener('click', async () => {
const canvas = await html2canvas(document.querySelector('#capture'));
const link = document.createElement('a');
link.download = 'report.png';
link.href = canvas.toDataURL('image/png');
link.click();
});
</script>
The element must be inside the DOM subtree passed to html2canvas. If you capture #capture, an iframe elsewhere on the page is irrelevant because it is never considered.
What the attribute does
html2canvas examines the target subtree while reconstructing the image. An element carrying data-html2canvas-ignore is left out of that rendering pass. The live iframe is not removed, navigated, or hidden for the user; only the generated canvas omits it.
When the attribute is the clearest choice
- You know exactly which frame should never appear in screenshots.
- You can add an attribute in a server-rendered template or component.
- You want the capture call itself to stay simple and reusable.
Ignore every iframe with ignoreElements
Use the ignoreElements callback when the markup is third-party, generated dynamically, or contains many frames.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →const canvas = await html2canvas(document.querySelector('#capture'), {
ignoreElements: (element) => element.tagName === 'IFRAME',
});
The callback receives each element considered for rendering. Returning true excludes that element. The tag name comparison is case-insensitive in normal HTML because element.tagName is exposed in uppercase, so 'IFRAME' is the appropriate comparison.
Keep selected iframes and omit the rest
Narrow the predicate when one embedded document is useful but advertisements, chat, or video frames are not.
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
const canvas = await html2canvas(document.querySelector('#capture'), {
ignoreElements: (element) => {
if (element.tagName !== 'IFRAME') return false;
return !element.matches('#trusted-map, .keep-in-export');
},
});
This leaves an iframe with either the trusted-map ID or the keep-in-export class eligible for rendering and ignores other iframes. Adjust the selector to match your own page; do not assume a class used by an embedded provider is stable.
Use a reusable capture function
async function captureWithoutIframes(selector) {
const target = document.querySelector(selector);
if (!target) throw new Error(`No element found for ${selector}`);
return html2canvas(target, {
ignoreElements: (element) => element.tagName === 'IFRAME',
});
}
const canvas = await captureWithoutIframes('#invoice');
document.body.append(canvas);
Checking the target before calling html2canvas gives a useful application error instead of a later null-reference failure.
Remove frames only from the cloned document with onclone
onclone is useful when the screenshot needs a temporary transformation but the visible page must not flicker or lose its embed. html2canvas clones the document for rendering and invokes this callback before it builds the canvas.
const canvas = await html2canvas(document.querySelector('#capture'), {
onclone: (clonedDocument) => {
clonedDocument.querySelectorAll('iframe').forEach((iframe) => iframe.remove());
},
});
The callback removes matching elements from the clone. The source document, including the user’s live iframe, remains in place. This is preferable to setting display: none on the real page and restoring it after an asynchronous capture.
Replace an iframe with a placeholder
Ignoring an element can leave its area empty because the surrounding layout still determines the capture geometry. If the exported image should show a label or a reserved box, replace the frame in the clone.
const canvas = await html2canvas(document.querySelector('#capture'), {
onclone: (clonedDocument) => {
clonedDocument.querySelectorAll('iframe').forEach((iframe) => {
const placeholder = clonedDocument.createElement('div');
placeholder.textContent = 'Embedded content omitted';
placeholder.style.cssText = [
'height:' + iframe.getBoundingClientRect().height + 'px',
'display:flex',
'align-items:center',
'justify-content:center',
'background:#f3f4f6',
'color:#4b5563',
'font:14px sans-serif',
].join(';');
iframe.replaceWith(placeholder);
});
},
});
Keep the replacement simple. The clone is a rendering input, not a second application, so event handlers and interactive behavior are unnecessary.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #3
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Iframe limitations you should understand
html2canvas does not take a literal screenshot of the browser’s final pixels. It reconstructs an image from DOM information, so the result can differ from what a user sees in a live tab. Its documentation explains that same-origin iframe content is supported recursively, while cross-origin frames and sandboxed frames without allow-same-origin cannot be accessed through contentDocument. Removing the iframe element avoids the need to inspect its contents.
Same-origin versus cross-origin
- Same-origin: html2canvas may inspect the frame recursively, subject to the library’s other rendering limits. You can still exclude it with any method above.
- Cross-origin: browser security prevents script from reading the frame’s document. Do not try to reach into
iframe.contentDocumentto hide it; match and ignore the iframe element itself. - Sandboxed without
allow-same-origin: treat it like an inaccessible frame and exclude the outer element.
These restrictions are about the browser security model, not a missing selector. They also mean that an exclusion rule should be tested against the outer iframe node, not content inside the embedded page.
Preserve the layout intentionally
If the frame occupies a fixed panel, decide whether the screenshot should retain that panel’s dimensions. ignoreElements and the data attribute skip rendering of the element; they do not redesign the surrounding layout. Use onclone to insert a same-sized placeholder when a blank region would confuse readers, or adjust the clone’s styles if the panel should collapse.
Common implementation mistakes
The iframe still appears
- Confirm that the iframe is inside the element passed to html2canvas.
- Check that the attribute is spelled exactly
data-html2canvas-ignore. - For a predicate, verify that it returns
truefor the actual node and that the callback is in the options object passed to this capture. - Make sure you are looking at a newly generated canvas, not an image cached from an earlier capture.
The whole capture fails after adding a rule
A callback that assumes every node has a property or calls matches on a non-element can throw. Keep the predicate defensive and return false for nodes you do not intend to omit. Also check the browser console for an exception in your own code before investigating iframe security.
Free tools Windows power users keep installed
One-click scans. No signup required.
The live page briefly loses its embed
This usually happens when application code removes or hides the real iframe before awaiting html2canvas. Move that mutation into onclone, or use ignoreElements so the source page is never changed.
The frame is gone but an unwanted blank box remains
That is a layout decision, not a failure to ignore. Replace the frame with a styled placeholder in onclone, or modify only the clone’s layout so the surrounding content closes the gap.
Rank #4
Images or text differ from the live page
Remember that html2canvas reconstructs from DOM and CSS rather than copying browser pixels. Fonts, filters, video frames, cross-origin resources, and timing-sensitive content can therefore differ. Capture after the target has reached the state you want, and avoid treating the result as a forensic pixel copy.
Performance and reliability considerations
- Capture the smallest useful subtree. Passing a dashboard panel instead of
document.bodyreduces the amount of DOM html2canvas must inspect. - Ignore expensive embeds early. A predicate or ignore attribute prevents iframe rendering work and avoids attempting to inspect inaccessible content.
- Keep clone work deterministic. In
onclone, perform synchronous DOM changes such as removal or replacement. Do not rely on a later user interaction to finish the transformation. - Use one rule per capture. If a report has different export policies, make the policy explicit in the options rather than permanently changing the page’s classes.
- Handle asynchronous errors. Wrap the promise in
try/catchand provide a retry or download-state message so a blocked resource does not leave the user guessing.
async function downloadCapture() {
try {
const canvas = await html2canvas(document.querySelector('#capture'), {
ignoreElements: (element) => element.tagName === 'IFRAME',
});
const blob = await new Promise((resolve) => canvas.toBlob(resolve, 'image/png'));
if (!blob) throw new Error('Canvas export returned no image');
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = 'capture.png';
link.click();
URL.revokeObjectURL(url);
} catch (error) {
console.error('Screenshot failed', error);
// Show an error state or retry control in your UI.
}
}
Ignoring an iframe does not grant access to its contents, bypass browser security, or make html2canvas a browser automation screenshot tool. The documented APIs belong specifically to html2canvas; verify the version installed by your project against its current documentation before relying on version-specific behavior.
Or skip the browser setup
If you need a screenshot of a remote URL rather than a canvas assembled in your page, ScreenshotNeo returns a PNG, JPEG, WebP, or PDF from one GET request. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing state with X-Page-Verdict and X-Billed headers. It is a different workflow from html2canvas: you provide a URL instead of running JavaScript in the page.
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)
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}`);
See the ScreenshotNeo documentation for authentication, output controls, and the complete parameter list. It supports full-page captures with lazy images loaded, CSS-selector element captures, dark mode, 12 device presets plus custom viewports, retina scale, PDF paper sizes and page ranges, custom CSS and JavaScript, pre-capture clicks, selector hiding, waits for a selector, delay, or network idle, request and resource blocking, custom headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, selectable cache TTLs, signed links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API, and an OpenAPI specification. Parameter names used by other screenshot APIs also work, which can simplify migration.
An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients, so an AI agent can request captures without you wiring a browser into your application.
Cost and billing
The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; yearly billing gives two months free. Every feature is available on every plan. Because failed loads and other non-clean results are marked in the response and are not billed, you can make retries without paying for those failed captures.
Recommended Free Tools
Create a free ScreenshotNeo account to get 1,000 screenshots each month without entering a card.
Best Value
FAQ
Will the ignore attribute work in Puppeteer or Playwright?
No. data-html2canvas-ignore, ignoreElements, and onclone are html2canvas mechanisms. Browser automation tools need their own page-level hiding or locator APIs.
Can I exclude an iframe without changing its source URL?
Yes. All three html2canvas methods act on the iframe element in the page you capture; none requires modifying the embedded document’s URL or code.
Does excluding a cross-origin iframe bypass CORS?
No. It avoids reading the frame’s document, but it does not relax same-origin or sandbox rules. The browser still enforces its normal security policy.
Can I use the same rule for a PDF generated by another library?
Not automatically. The options described here are html2canvas-specific. Check the PDF or screenshot library’s own exclusion API before reusing the attribute or callback.
Frequently Asked Questions
Will the ignore attribute work in Puppeteer or Playwright?
No. data-html2canvas-ignore, ignoreElements, and onclone are html2canvas mechanisms; browser automation tools require their own APIs.
Can I exclude an iframe without changing its source URL?
Yes. The html2canvas rules act on the iframe element in the captured page and do not require changing the embedded URL.
Does excluding a cross-origin iframe bypass CORS?
No. It avoids reading the frame’s document but does not relax the browser’s same-origin or sandbox security rules.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesCan I reuse these options in another screenshot library?
No assumption is safe. Verify that library’s documented exclusion mechanism; these options belong to html2canvas.
Quick Recap
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.

