防止点击事件时浏览器弹出
在基于 jquery-mobile 的网络应用程序中,我如何防止默认浏览器菜单在“点击保持”时显示.. 相反,我想显示自定义对话框页面..
下面提到的是我现在的代码..
$(".task_row").bind('taphold',function(event, ui){
event.preventDefault();
$("#slide_down_menu").trigger('click');
});
In a jquery-mobile based web app, how do i prevent the default browser menu from showing on "tap hold" .. instead i want to show a custom dialog page ..
mentioned below is my code as of now ..
$(".task_row").bind('taphold',function(event, ui){
event.preventDefault();
$("#slide_down_menu").trigger('click');
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
使用 css:
不显示标准对话框
use css:
to not show the standard dialog
问题在于,您绑定的“taphold”事件是由 jQuery Mobile 触发的自定义事件,因此它与触发浏览器默认行为的事件不同。
如果您试图避免使用允许您“打开”或“复制”网址的默认菜单,那么一种解决方案是不使用
标记。如果您使用 span 或 div,则可以将 ontap 函数绑定到它,该函数将更改浏览器的位置,并且您的 taphold 事件不会因默认行为而中断。
The trouble is that the 'taphold' event that you are binding to is a custom event that is triggered by jQuery Mobile, so it is not the same event that triggers the browser's default behavior.
If the default menu you are trying to avoid is the one that allows you to "Open" or "Copy" the url, then one solution is to not use an
<a>
tag. If you use a span or a div, you can bind an ontap function to it that will change the browser's location, and your taphold event will not be interrupted with the default behavior.我发现你必须禁用右键单击。
I found out you have to disable right-clicking.
使用
ontouchstart
事件怎么样?我很确定我已经使用它来防止发生默认的 iPad 交互。What about using the
ontouchstart
event? I'm pretty sure I've used this to prevent the default iPad interactions from occuring.你已经很接近了。正确的代码是:
You were pretty close with it. The correct code is:
我刚刚取下链接并应用了 css 使其看起来像一个,并使用了这个
$.mobile.changePage( "#main", {transition: "slideup"} );
但我已经有了它绑定到显示删除按钮的单击事件...不再有弹出菜单
I just took off the link and applied css to make it look like one and used this
$.mobile.changePage( "#main", { transition: "slideup"} );
but i already had it bound to a click event that shows a delete button... no more popup menu