0

I want to create my own context menu that changes depending on where I click on the screen.

However I don't want to lose the easy access to chrome dev tools via right click > inspect. Ideally I want to add my own entry that only appears if I compile the program in DEBUG.

Can this be done? Or is it prevented to avoid websites being annoying?

Thanks.

4

1 Answer 1

3

Instead of replacing browser's contextmenu with yours, you could add entries to it, so you won't lose "Inspect" command.

To do that, you can use HTML5 <menu>.

You can read a tutorial here: http://davidwalsh.name/html5-context-menu

<section contextmenu="mymenu">
    <!-- Content -->
</section>

<menu type="context" id="mymenu">
    <menuitem label="Refresh Post" onclick="window.location.reload();" icon="/images/refresh-icon.png"></menuitem>
    <menuitem label="Skip to Comments" onclick="window.location='#comments';" icon="/images/comment_icon.gif"></menuitem>
    <menu label="Share on..." icon="/images/share_icon.gif">
        <menuitem label="Twitter" icon="/images/twitter_icon.gif" onclick="goTo('//twitter.com/intent/tweet?text=' + document.title + ':  ' + window.location.href);"></menuitem>
        <menuitem label="Facebook" icon="/images/facebook_icon16x16.gif" onclick="goTo('//facebook.com/sharer/sharer.php?u=' + window.location.href);"></menuitem>
    </menu>
</menu>

But be aware that it is not widely supported.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.