How to enable the right-click (with the new tab option) on an input or button

Asked

Viewed 178 times

1

I have a input I would like the option to appear when right-clicking abrir link em uma nova guia.

How can I do it, is possible only with css and html, taking into consideration that this same button will trigger a submit ?

  • Like this: http://codepen.io/anon/pen/egpMEP ?

  • I thought I’d open the native OS window myself, but that in the click to new tab it already opened the result page of Submit... but it’s like this

  • I don’t know how to manipulate it. See you later, hugs.

  • Tmb Naum heuheuhue

  • I believe there is no way. I have never seen in my entire life. (25 years, 8 programmer)

1 answer

0

With javascript I made a little beast just joke...

<script>
    function detectLeftButton(evt) {
        evt = evt || window.event;
        var button = evt.which || evt.button;
        if(button == 1) {
            // ação para o botão esquerdo
			
        } else if(button == 2) {
            // ação para a rodinha do mouse
        } else if(button == 3) {
            // ação para o botão direito
			
			document.getElementById("menu").style.display='block';
			
        }
    }

    window.onmousedown = detectLeftButton;
</script>

<a href="http://www.google.com">Google</a>
<div id="menu" style="position:relative; top:-20px; left:-2px; display:none">
	<form action="http://www.google.com" method="post">
		<input type="submit" value="Abrir em nova aba">
	</form>
</div>

But I think this pure CSS tooltip here is close to what you want:

It is possible to make a tooltip with pure CSS?

With javascript, they made here a section much closer to what you need than the one I made above:

How to create a custom context menu?

But it still does not control to open new tab.

  • I liked that action "http://www.google.com" but that is not the intention

Browser other questions tagged

You are not signed in. Login or sign up in order to post.