Create Custom Right-Click Context Menus with justContext.js

Every web browser has a default context menu. This appears when a user right-clicks anywhere on a page and it customarily has a same options, such as “copy”, “save”, or “inspect element”.

With a justContext library, we can build specialized context menus for any elements on your site. These can be auto-populated with anything we like and we can write tradition functions to run whenever a user clicks an choice in your tradition menu.

justContext pluginjustContext plugin

Any page component can support a possess context menu. This means we can target particular items such as slideshows or HTML5 video players, or we can target a whole page body.

You have full control over a theming of a context menu, including fonts, colors, icons, and even separators to order your menu into sections. This plugin unequivocally lets we emanate a full context menu from scratch with any facilities we like.

By default, justContext comes with two themes: dark and light. You can select between them and find whichever one best matches your website.

Each thesis can be customized regulating opposite Google Web Fonts, not to discuss a whole Font Awesome library is finished by default.

Check out a live demo to see it in action. It works in all browsers solely Internet Explorer though this shouldn’t be a problem deliberation Microsoft’s pull to a new Edge browser.

justContext.js demojustContext.js demo

Creating a tangible context menu is a small tricky. It requires a few CSS classes and it’s all hard-coded in HTML into your web page.

Here’s a sample from a main repo on GitHub:

ul class="jctx jctx-id-foo jctx-black jctx-black-shadow"
	li data-action="cut"Cut/li
	li data-action="copy"Copy/li
	li data-action="paste"Paste/li
	hr
	li data-action="new_pkg"New package/li
 li data-action="new_cls"New class/li
	li data-action="new_intf" class="disabled"New interface
 (a infirm entry)/li
/ul

If you’re peaceful to tinker with settings we can do a lot with this plugin. But, we also acknowledge it’s a niche-specific resource that won’t be profitable to all websites.

Regardless of because or how you’d use it, justContext is a comprehensive best apparatus for creating web context menus from scratch. All support is accessible on GitHub and a plugin is 100% giveaway to use on any web project.

Add Comment