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

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 javascript:void(document.oncontextmenu = null); to clear a context-menu handler assigned through document.oncontextmenu on the current page. It may restore the browser’s right-click menu, but it is not a universal way to remove every protection. The JavaScript literal is lowercase null; Null is a different identifier and normally causes a ReferenceError. This is a temporary, page-only change—not a permanent browser setting or a way to bypass authentication, paywalls, DRM, or server-side controls.

What the snippet does

A page can react to an attempted right-click by handling the contextmenu event and cancelling its default action. The event is normally generated by the right mouse button or the keyboard context-menu key. A common property-based block looks like this:

document.oncontextmenu = () => false;

The one-line reset is:

javascript:void(document.oncontextmenu = null);

Its parts have distinct jobs:

  • document: the current page’s document object.
  • .oncontextmenu: the event-handler property for context-menu events.
  • = null: removes the function assigned to that property. It does not remove all context-menu listeners.
  • void(...): evaluates the assignment and returns undefined. In a javascript: URL, this prevents a returned value from replacing the page. See MDN’s void operator reference.
  • javascript:: the URL scheme that tells the browser to evaluate the following code in the current page.

JavaScript’s null literal is always lowercase. MDN’s null reference explains why Null is not equivalent.

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

How to run it

Method 1: Use the address bar

  1. Open the page where right-click is disabled.
  2. Focus the address bar.
  3. Type or paste the complete code, including javascript::
javascript:void(document.oncontextmenu = null);
  1. Press Enter, then try right-clicking.

Some browsers or browser interfaces remove or reject a pasted javascript: prefix as a safety measure. If nothing changes, use the DevTools Console method.

#1 Best Overall
Sale
Logitech M185 Compact Ambidextrous Wireless Mouse with Rubber Grips - Blue
  • Compact Mouse: With a comfortable and contoured shape, this Logitech ambidextrous wireless mouse feels great in either right or left hand and is far superior to a touchpad
  • Durable and Reliable: This USB wireless mouse features a line-by-line scroll wheel, up to 1 year of battery life (2) thanks to a smart sleep mode function, and comes with the included AA battery
  • Universal Compatibility: Your Logitech mouse works with your Windows PC, Mac, or laptop, so no matter what type of computer you own today or buy tomorrow your mouse will be compatible
  • Plug and Play Simplicity: Just plug in the tiny nano USB receiver and start working in seconds with a strong, reliable connection to your wireless computer mouse up to 33 feet / 10 m (5)
  • Better than touchpad: Get more done by adding M185 to your laptop; according to a recent study, laptop users who chose this mouse over a touchpad were 50% more productive (3) and worked 30% faster (4)

Method 2: Chrome DevTools Console

Chrome documents the Console as a place to evaluate JavaScript and modify the current page. Open it with Ctrl+Shift+J on Windows, Linux, or ChromeOS, or Command+Option+J on macOS, as described in Chrome’s Console guide.

Run this expression and press Enter:

document.oncontextmenu = null;

If the property is attached to another global object, you can reset the common properties together:

window.oncontextmenu = null;
document.oncontextmenu = null;
if (document.body) document.body.oncontextmenu = null;

These assignments still do not unregister listeners installed with addEventListener().

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.

If Chrome refuses pasted Console code

Chrome may show a self-XSS warning and block pasting. Its documented override is to type allow pasting manually, then paste only code you have read and understand. Chrome explains the risk in its self-XSS protection guidance: arbitrary Console code can expose account information or perform unwanted actions.

Rank #2
Sale
Logitech M240 Compact Silent Bluetooth Wireless Mouse - Graphite
  • Pair and Play: With fast, easy Bluetooth wireless technology, you’re connected in seconds to this quiet cordless mouse —no dongle or port required
  • Less Noise, More Focus: Silent mouse with 90% reduced click sound and the same click feel, eliminating noise and distractions for you and others around you (1)
  • Long-Lasting Battery Life: Up to 18-month battery life with an energy-efficient auto sleep feature, so you can go longer between battery changes (2)
  • Comfortable, Travel-Friendly Design: Small enough to toss in a bag; this slim and ambidextrous portable compact mouse guides either your right or left hand into a natural position
  • Long-Range: Reliable, long-range Bluetooth wireless mouse works up to 10m/33 feet away from your computer (3)

Other property and inline-handler fixes

Remove inline attributes from elements

A page may put the handler directly in HTML, for example <body oncontextmenu="return false">. This command removes those attributes from elements currently in the document:

document.querySelectorAll("[oncontextmenu]").forEach(element => {
  element.removeAttribute("oncontextmenu");
});

It does not remove listeners installed with addEventListener(), and scripts can add the attributes again later.

Check where property handlers exist

Use this diagnostic expression to inspect the most common locations:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
[
  window.oncontextmenu,
  document.oncontextmenu,
  document.body?.oncontextmenu
];

A function value indicates a property handler is present; null means that particular property is empty. Descendant elements can still have their own handlers.

Rank #3
Afaartcci Rechargeable Wireless Mouse, Silent Bluetooth Mouse (Black)
  • 【Dual Mode Wireless Bluetooth Mouse】: Switch easily between two devices—connect one via Bluetooth (BT5.2/3.0) and the other using a 2.4G USB receiver. No drivers needed; just plug and play. Enjoy a reliable connection up to 33 feet. Note: You can't use both modes simultaneously; the USB receiver is stored in the mouse.
  • 【Rechargeable Wireless Mouse】: Equipped with a 500mAh lithium-ion battery, it charges in 2 hours for over 7 days of use and 30 days on standby. The mouse sleeps after 5 minutes of inactivity to save power and can be woken with any click.
  • 【Colorful LED Breathing Light】: Features 7 colorful LED lights that change randomly, adding a fun atmosphere to your workspace.
  • 【Portable Mouse】Compact size (4.4 x 2.3 x 1.1 inches) makes it easy to fit in your laptop bag. Lightweight and ergonomic, it's perfect for travel. Contact us anytime for support.
  • 【Wide Compatibility】: Works with laptops, PCs, tablets, and smartphones across various operating systems, including Android, Windows, and Mac. Ideal for home, office, and travel.

Why the one-line reset may fail

The page uses addEventListener()

This block is independent of the oncontextmenu property:

document.addEventListener("contextmenu", event => {
  event.preventDefault();
});

Setting document.oncontextmenu = null does not remove it. Normally, removal requires the same function reference and matching options:

function blockMenu(event) {
  event.preventDefault();
}

document.addEventListener("contextmenu", blockMenu);
document.removeEventListener("contextmenu", blockMenu);

On a third-party page, you usually do not have the original function reference, so there is no dependable universal one-line removal command. The distinction between event properties and listeners is covered in MDN’s contextmenu event documentation.

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

The handler is on a different element

Examples include document.body.oncontextmenu or a specific content element’s oncontextmenu. Resetting only document.oncontextmenu will not affect those locations.

Rank #4
Logitech M510 Full Size Ambidextrous 2.4 GHz Wireless Mouse
  • Your hand can relax in comfort hour after hour with this ergonomically designed mouse. Its contoured shape with soft rubber grips, gently curved sides and broad palm area give you the support you need for effortless control all day long.
  • You’ve got the control to do more, faster. Flipping through photo albums and Web pages is a breeze, especially for right-handers—with three standard buttons plus Back/Forward buttons that you can also program to switch applications, go full screen and more. And side-to-side scrolling plus zoom gives you the power to scroll horizontally and vertically through your music library, maps and Facebook feeds, and zoom in and out of photos and budget spreadsheets with a click.* * Requires Logitech SetPoint software (Windows) or Logitech Control Center software (Mac OS X)
  • Two years of battery life practically eliminates the need to replace batteries. ** The On/Off switch helps conserve power, smart sleep mode extends battery life and an indicator light eliminates surprises. ** Battery life may vary based on user and computing conditions.
  • The tiny Logitech Unifying receiver stays in your laptop. There’s no need to unplug it when you move around, so there’s less worry of it being lost. And you can easily add compatible wireless mice and keyboards to the same wireless receiver.

Another event is being blocked

Applications can intercept mousedown, mouseup, pointerdown, pointerup, click, or auxclick instead of—or as well as—contextmenu. In that case, clearing one property does not restore normal pointer behavior.

An overlay receives the pointer

An invisible or transparent layer can sit above the visible text or image. The browser then targets the overlay, so changing an event handler does not fix the underlying hit-testing or layout.

The application has its own menu

Some web apps replace the browser menu with a custom menu. Removing one handler may do nothing or leave the application in an unexpected state.

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

The content is inside an iframe

JavaScript runs in the current browsing context. If the target is inside an iframe, select that frame’s execution context in DevTools before running the command. Chrome documents context selection in its Console reference. Cross-origin restrictions can prevent access to a frame’s document.

Best Value
Sale
Acer Wireless Mouse for Laptop, 2.4GHz Computer Mouse 3 Adjustable 1600 DPI
  • 【Plug and Play for Home/Office/School】The wireless computer mouse features 2.4GHz connectivity, delivering a stable, interference-free connection up to 32ft. Designed for 𝐦𝐞𝐝𝐢𝐮𝐦 𝐭𝐨 𝐥𝐚𝐫𝐠𝐞 𝐬𝐢𝐳𝐞𝐝 𝐡𝐚𝐧𝐝𝐬, it ensures comfortable use all day. Simply plug in the USB-A receiver for instant pairing—no drivers needed. 📌📌 If the mouse isn’t suitable, place the USB receiver in the battery compartment and return both.
  • 【3 Levels Adjustable DPI】This travel USB mouse offers 3 adjustable DPI settings (800, 1200, 1600), allowing you to customize sensitivity for precise design work. Effortlessly switch to match your task and elevate your productivity. 📌 Please remove the film at the bottom of the mouse before use.
  • 【Effortless Browsing】Equipped with forward and backward buttons, this computer mice streamlines your workflow, making it easy to navigate through web pages and files with a simple click. 📌Side button does not work on Mac.
  • 【Visible Indicator Light】 The pc mouse features a visual indicator for DPI levels and low battery alerts. The red light flashes once for 800 DPI, twice for 1200 DPI, and three times for 1600 DPI. When the battery level is below 10%, the light flashes red until the mouse is completely out of power.
  • 【Click to Wake】With smart sleep mode, it saves power by standby after 10 inactive minutes, just 2-3 clicks to wake. This efficient design delivers 3x longer battery life than motion-wake mice. Engineered for durability, its buttons and scroll wheel are tested for 10 million clicks, ensuring long-term reliability and consistent performance.

The page reinstalls the block

If right-click works briefly and then stops, a script probably assigned the handler again. The reset affects the current state only and is not persistent.

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

Fallbacks when you only need the content

  • Firefox: holding Shift while right-clicking can show the context menu without firing the page’s contextmenu event, according to MDN.
  • Keyboard controls: use the keyboard context-menu key or the browser’s supported shortcut.
  • Developer tools: use Inspect, View Source, or Save Page when those options are appropriate.
  • Official alternatives: look for a publisher-provided download, transcript, export, or accessible text version.

Temporarily disable JavaScript in Chrome

If the restriction is entirely JavaScript-based, disabling JavaScript before a reload may restore ordinary browser behavior. Chrome’s documented workflow is:

  1. Open DevTools.
  2. Press Ctrl+Shift+P on Windows or Linux, or Command+Shift+P on macOS.
  3. Search for Disable JavaScript and select it.
  4. Reload the page.
  5. Run Enable JavaScript afterward, or close DevTools to restore the normal state.

See Chrome’s JavaScript-disable instructions. Chrome keeps JavaScript disabled in that tab while DevTools is open. This can break logins, navigation, menus, video players, rendering, and other application features, so treat it as a diagnostic fallback rather than a routine setting.

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

What this technique cannot bypass

  • Administrator browser policies, extensions, or operating-system restrictions.
  • Protected application surfaces or device-level limitations.
  • Server-side authorization, authentication, paywalls, DRM, or download controls.

A disabled context menu is usually a client-side user-interface restriction, not proof that the underlying content is securely protected. Use copying, saving, and inspection only in ways permitted by the site, your organization, and applicable law.

Quick troubleshooting

Symptom Likely cause What to try
Nothing happens The address-bar prefix was stripped, or the page uses another mechanism. Use the DevTools Console and test the property and listener possibilities.
Null is not defined Null is not JavaScript’s null literal. Use lowercase null.
It works until reload The change is local to the current page state. Run it again after reload; it is not a permanent browser setting.
Right-click works on some elements only Handlers are attached to particular elements or an overlay changes the target. Inspect inline attributes, element properties, and layout.
Chrome will not let me paste DevTools self-XSS protection is active. Type allow pasting yourself only after reviewing the command.
The page breaks after disabling JavaScript The application depends on JavaScript. Re-enable JavaScript and use a narrower property reset or an official content option.
The content is in an iframe The command ran in the top document rather than the frame. Select the iframe’s DevTools execution context; cross-origin access may still be unavailable.

The Bottom Line

javascript:void(document.oncontextmenu = null); is a useful, limited reset for one event-handler property. If it fails, the page is probably using listeners, element-specific logic, another pointer event, an overlay, an iframe, or a script that restores the block.

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.