diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:41:15 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:41:15 -0500 |
commit | 4b1a9203c547c019fc5398082ae19a3f3d4c3efe (patch) | |
tree | d4a40e13ceeb9f85479605110a76e7a4d5f3b56b /files/ca/web/html/global_attributes/contextmenu/index.html | |
parent | 33058f2b292b3a581333bdfb21b8f671898c5060 (diff) | |
download | translated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.tar.gz translated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.tar.bz2 translated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.zip |
initial commit
Diffstat (limited to 'files/ca/web/html/global_attributes/contextmenu/index.html')
-rw-r--r-- | files/ca/web/html/global_attributes/contextmenu/index.html | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/files/ca/web/html/global_attributes/contextmenu/index.html b/files/ca/web/html/global_attributes/contextmenu/index.html new file mode 100644 index 0000000000..220950716f --- /dev/null +++ b/files/ca/web/html/global_attributes/contextmenu/index.html @@ -0,0 +1,117 @@ +--- +title: contextmenu +slug: Web/HTML/Global_attributes/contextmenu +tags: + - Global attributes + - HTML + - Reference +translation_of: Web/HTML/Global_attributes/contextmenu +--- +<div>{{HTMLSidebar("Global_attributes")}}</div> + +<p>L'<a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes">atribut global</a> <code><strong>contextmenu</strong></code> és l'<strong><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id">id</a></strong> d'un {{HTMLElement("menu")}} per ser utilitzat com el menú contextual d'aquest element.</p> + +<p>Un <em>menú contextual</em> és un menú que apareix després de la interacció de l'usuari, com un clic dret. HTML5 ara ens permet personalitzar aquest menú. Aquests són alguns exemples d'implementació, incloent menús niats.</p> + +<h2 id="Exemple">Exemple</h2> + +<h3 id="HTML">HTML</h3> + +<pre class="brush:html; highlight:[1,10,15]"><body contextmenu="share"> + <menu type="context" id="share"> + <menu label="share"> + <menuitem label="Twitter" onclick="shareViaTwitter()"></menuitem> + <menuitem label="Facebook" onclick="shareViaFacebook()"></menuitem> + </menu> + </menu> + <ol> + <li> + Anywhere in the example you can share the page on Twitter and + Facebook using the Share menu from your context menu. + </li> + <li contextmenu="changeFont" id="fontSizing"> + On this specific list element, you can change the size of the text + by using the "Increase/Decrease font" actions from your context menu + </li> + <menu type="context" id="changeFont"> + <menuitem label="Increase Font" onclick="incFont()"></menuitem> + <menuitem label="Decrease Font" onclick="decFont()"></menuitem> + </menu> + <li contextmenu="ChangeImage" id="changeImage"> + On the image below, you can fire the "Change Image" action + in your Context Menu.<br /> + <img src="https://developer.mozilla.org/media/img/promote/promobutton_mdn5.png" + contextmenu="ChangeImage" id="promoButton" /> + <menu type="context" id="ChangeImage"> + <menuitem label="Change Image" onclick="changeImage()"></menuitem> + </menu> + </li> + </ol> +</body> +</pre> + +<h3 id="JavaScript">JavaScript</h3> + +<pre class="brush:js">function shareViaTwitter() { + window.open("https://twitter.com/intent/tweet?text=" + + "Hurray! I am learning ContextMenu from MDN via Mozilla"); +} + +function shareViaFacebook() { + window.open("https://facebook.com/sharer/sharer.php?u=" + + "https://developer.mozilla.org/en/HTML/Element/Using_HTML_context_menus"); +} + +function incFont() { + document.getElementById("fontSizing").style.fontSize = "larger"; +} + +function decFont() { + document.getElementById("fontSizing").style.fontSize = "smaller"; +} + +function changeImage() { + var index = Math.ceil(Math.random() * 39 + 1); + document.images[0].src = + "https://developer.mozilla.org/media/img/promote/promobutton_mdn" + + index + ".png"; +}</pre> + +<h3 id="Resultat">Resultat</h3> + +<p>{{EmbedLiveSample("Example", "100%", 400)}}</p> + +<h2 id="Especificacions">Especificacions</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Especificació</th> + <th scope="col">Estat</th> + <th scope="col">Comentari</th> + </tr> + <tr> + <td>{{SpecName('HTML WHATWG', "forms.html#attr-contextmenu", "contextmenu")}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td>Sense canvis des de l'última instantània, {{SpecName('HTML5.1')}}</td> + </tr> + <tr> + <td>{{SpecName('HTML5.1', "interactive-elements.html#context-menus", "contextmenu")}}</td> + <td>{{Spec2('HTML5.1')}}</td> + <td>Instantània de {{SpecName('HTML WHATWG')}}, definició inicial.</td> + </tr> + </tbody> +</table> + +<h2 id="Navegadors_compatibles">Navegadors compatibles</h2> + +<p>{{Compat("html.global_attributes.contextmenu")}}</p> + +<p>[1] Una implementació experimental està disponible a través de l'opció de línia d'ordres <code>--enable-blink-features=ContextMenu</code>. Fins Chrome 52 i Opera 39 estava disponible l'opció d'habilitació de les <em>característiques de la Plataforma Web Experimental</em>, però va ser eliminada a causa d'un <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=412945">problema de compatibilitat web</a>. El suport per aquesta caracteristica se sol·licita en <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=87553">Chromium bug 87553</a>.</p> + +<h2 id="Veure">Veure</h2> + +<ul> + <li>Tots els <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes">atributs globals</a>.</li> + <li>{{domxref("HTMLElement.contextMenu")}}</li> +</ul> |