本文介绍了添加到浏览器的右键菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能项目添加到默认的浏览器右键单击菜单?
Is it possible to add item to the default browser right button click menu?
推荐答案
在2010年,你必须的引发相当于为浏览器并没有原生支持这种行为。
In 2010, you had to replace the context menu with your own JavaScript triggered equivalent as browsers didn't support this behaviour natively.
不过,现在的浏览器已经实现了,您可以添加到现有的上下文菜单。
However, now browsers have implemented the menu
element where you can add to the existing context menu.
<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>
要做出一个元素使用右键菜单中添加文本菜单=利用这项
属性吧。你可以在这里看到利用这项
的 ID匹配
的菜单中的属性
元素。
To make an element use this context menu, add the contextmenu="mymenu"
attribute to it. You can see here that mymenu
matches the id
attribute of the menu
element.
这篇关于添加到浏览器的右键菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!