Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Use jQuery to select the element, pass the underlying DOM node to html2canvas(), and export the returned canvas as a PNG. The essential call is html2canvas($('#capture')[0]); [0] unwraps the jQuery object into the DOM element the library expects.
This is a browser-side reconstruction of the page, not a pixel-for-pixel photograph of the browser window. It is useful for content your page controls, but cross-origin resources, iframes, unsupported CSS and very large canvases can change or prevent the result.
What you need before writing the code
- A page containing jQuery and html2canvas.
- A target element with a stable selector, such as
#capture. - A user action, normally a button click, to start the capture.
- Permission to read the images and frames inside the target. Browser same-origin rules still apply.
The examples below assume both libraries are already loaded by your normal dependency method. html2canvas uses window, document and computed styles, so run this code in a browser page rather than Node.js.
Free tools Windows power users keep installed
One-click scans. No signup required.
Basic jQuery screenshot and download
Give the area you want to capture an ID, add a button, then convert the resolved canvas to a data URL. A temporary anchor starts the download without navigating away from the page.
#1 Best Overall
<div id='capture'>
<h1>Quarterly report</h1>
<p>This panel will be captured.</p>
</div>
<button id='save' type='button'>Save screenshot</button>
<script>
$('#save').on('click', function () {
var target = $('#capture')[0];
if (!target) {
console.error('No element matched #capture');
return;
}
html2canvas(target).then(function (canvas) {
var link = document.createElement('a');
link.download = 'screenshot.png';
link.href = canvas.toDataURL('image/png');
link.click();
}).catch(function (error) {
console.error('Screenshot failed:', error);
});
});
</script>
The Promise resolves to a canvas. toDataURL('image/png') encodes that canvas, and the temporary link supplies the filename. Check that the selector matches exactly one visible target; if it matches nothing, [0] is undefined.
Capture a whole page or a selected region
Capture the page content
For a page-level capture, pass the element that contains the page content, often a dedicated wrapper or document.body:
$('#save-page').on('click', function () {
html2canvas(document.body).then(function (canvas) {
var link = document.createElement('a');
link.download = 'page.png';
link.href = canvas.toDataURL('image/png');
link.click();
});
});
A DOM render is limited to what html2canvas can inspect and what the browser can fit in a canvas. It does not include browser chrome such as the address bar, tabs or extensions.
Capture one component
jQuery remains useful for finding a card, chart or modal; pass the first matched DOM node, not the jQuery collection:
var card = $('.invoice-card')[0];
if (card) {
html2canvas(card).then(function (canvas) {
document.querySelector('#preview').replaceChildren(canvas);
});
}
If a selector can match several elements, decide whether to capture the first one, loop over all matches, or require a unique ID. Passing $('.invoice-card') directly is incorrect because html2canvas expects a DOM element.
Crop a rectangle
The x, y, width and height options crop the rendered area. Coordinates are page coordinates relative to the document:
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
html2canvas($('#capture')[0], {
x: 40,
y: 120,
width: 640,
height: 360
}).then(function (canvas) {
document.body.appendChild(canvas);
});
Use this when the target element is larger than the portion you need. Verify the coordinates at the viewport size used by your users.
Control resolution and excluded elements
Produce a higher-density image
Set the documented scale option. Using window.devicePixelRatio generally gives a sharper result on high-DPI displays, while increasing memory use:
html2canvas($('#capture')[0], {
scale: window.devicePixelRatio
}).then(function (canvas) {
var png = canvas.toDataURL('image/png');
console.log('pixel size:', canvas.width, canvas.height);
});
For very large targets, a lower fixed scale can avoid browser canvas limits. Treat maximum dimensions as browser- and platform-dependent rather than relying on one universal number.
Ignore controls, ads or sensitive fields
Add data-html2canvas-ignore to any element that should not appear:
<button data-html2canvas-ignore='true'>Edit</button>
<aside class='chat' data-html2canvas-ignore='true'>Support</aside>
html2canvas skips marked nodes while walking the DOM. This is useful for removing a download button, a live chat launcher or private controls from the exported image.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Request cross-origin images
The examples document useCORS: true for images hosted on another origin:
Rank #3
html2canvas($('#capture')[0], {
useCORS: true
}).then(function (canvas) {
var image = canvas.toDataURL('image/png');
document.querySelector('#preview').src = image;
});
This option only asks the remote server to permit the request. The image server must send appropriate cross-origin headers; useCORS cannot bypass another origin’s security policy. If a resource is not permitted, the canvas may become tainted and refuse export.
What html2canvas actually captures
html2canvas walks the DOM and rebuilds an image from the elements, styles and assets it understands. It does not read the browser’s final pixels. Unsupported or partially supported CSS can therefore be missing or look different from the live page.
- It is a good fit for an in-page panel, invoice, dashboard or other DOM you control.
- It is not a guarantee of pixel-perfect reproduction of every browser effect.
- Browser chrome is outside the DOM and cannot be included by this script.
- Third-party resources remain subject to browser security rules.
Cross-origin images and iframes
Images from another origin
Canvas export requires readable image data. Same-origin images normally work; otherwise the image host must opt in with cross-origin headers, or you need a server-side proxy that fetches the resource and serves it from an allowed origin. Do not treat a proxy as a way to ignore licensing or access controls.
Embedded frames
A cross-origin iframe cannot be traversed through its contentDocument, so html2canvas cannot inspect and reconstruct its contents from your page. Same-origin frames may be accessible, but sandbox attributes can still restrict access. If an embedded payment form, video player or social widget is hosted elsewhere, do not promise that it will appear in the output.
Reliable capture flow
- Choose a stable target. Prefer a wrapper with a fixed ID over a broad selector such as
div. - Start after the UI is ready. Bind the capture to a click or another point at which the target is present and visible.
- Validate the match. Check the result of
$('#capture')[0]before calling html2canvas. - Set only the options you need. Add cropping, scaling, ignored nodes or
useCORSdeliberately. - Handle the Promise. Provide a
catchhandler and tell the user when the export fails. - Test representative browsers and sizes. Canvas limits and CSS rendering vary by browser and platform.
Troubleshooting common failures
html2canvas is not defined
The library was not loaded, loaded after your script, or failed to load. Check the browser console and network panel, then ensure your application initializes the click handler only after html2canvas is available.
$ is not a function or the selector returns nothing
jQuery is missing, loaded in the wrong order, or the selector does not match the markup. Confirm that jQuery loads first, inspect $('#capture').length, and run the handler after the target exists.
Rank #4
- 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
The export throws a security or tainted-canvas error
Inspect images and other assets inside the target. Move them to the same origin, configure the asset server for cross-origin access, or use an appropriately configured proxy. useCORS alone cannot override the remote server.
Windows 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 reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteA third-party iframe is blank or missing
This is expected for a cross-origin frame because the browser blocks document access. Capture content you own from the frame’s own page, or use a real-browser server workflow that has permission to load the complete page.
The image is blank or only partly rendered
The canvas may exceed a browser or platform limit, or the page may contain unsupported styles or inaccessible assets. Reduce scale, crop the target, split a very long page into sections, and remove or replace blocked resources. The exact maximum canvas size is not universal.
The result is blurry
Increase scale, commonly to window.devicePixelRatio, and check the resulting pixel dimensions. Higher scale consumes more memory and can make large captures fail, so adjust both together.
The download does not start
Make sure the code runs in response to the user’s click, that the Promise resolves, and that the anchor has both download and a PNG data URL. Log the caught error and test whether appending the generated canvas to the document works before troubleshooting the download itself.
When a browser-side reconstruction is the wrong tool
| Requirement | Better fit | Reason |
|---|---|---|
| Capture a component the current user can see | jQuery plus html2canvas | Runs in the page and can target one DOM node. |
| Render a page on a server or in a job queue | Puppeteer or Playwright | They drive a real browser instead of relying on the current page’s DOM and origin permissions. |
| Capture a browser tab or include browser UI | Native browser-extension screenshot APIs | An extension has APIs that a normal page script does not. |
| Include arbitrary third-party pages without changing their code | Server-side browser capture or a screenshot API | Cross-origin frames and assets can block a client-side DOM walk. |
Choose based on four questions: must the output match actual browser pixels, where will the capture run, does the page contain cross-origin content, and do you need one selected element or an entire page?
Best Value
Or skip the browser setup
ScreenshotNeo provides a website screenshot API and MCP server when you need a server-side capture rather than code running inside the page. One GET request returns PNG, JPEG, WebP or a PDF.
For a direct capture, use the API base https://api.screenshotneo.com/v1/shot:
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, parameters and response handling. Before capture, it can accept cookie and consent banners like a visitor and remove more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the result with X-Page-Verdict and X-Billed.
For workflows beyond a single URL, ScreenshotNeo supports full-page capture with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets plus custom viewports, retina scale, PDF paper size/margins/orientation/page ranges, HTML or CSS to image, custom JavaScript and CSS, pre-capture clicks, hidden selectors, waits for a selector, delay or network idle, blocking ads/trackers/requests/resource types, custom headers/cookies/user agents/Authorization, timezone and geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image 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. Every feature is included on every plan.
| Plan | Included screenshots | Price |
|---|---|---|
| Free | 1,000 per month | $0, no card |
| Starter | 3,000 | $5 |
| Growth | 15,000 | $15 |
| Pro | 60,000 | $39 |
| Scale | 250,000 | $99 |
| Business | 1,000,000 | $249 |
Yearly billing provides two months free. An MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients, so an AI agent can request captures without custom browser plumbing.
Create a free ScreenshotNeo account for 1,000 screenshots each month with no card required.
FAQ
Can jQuery capture the browser address bar or tabs?
No. The script receives DOM content from the page, not the browser window or its controls. Use a browser-extension screenshot API when the browser surface itself is required.
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 use this method for a background server job?
Not directly. html2canvas depends on the live browser page; use Puppeteer, Playwright or a screenshot API such as ScreenshotNeo for unattended server captures.
Frequently Asked Questions
Can jQuery capture the browser address bar or tabs?
No. html2canvas receives page DOM content, not browser chrome. A browser-extension screenshot API is required for the browser surface itself.
Can this run as an unattended server job?
The browser-side method depends on a live page. For scheduled or server-side work, use Puppeteer, Playwright or a hosted screenshot API.
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.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.

