我使用zepto的longtap事件 长按某个图片750ms毫秒后触发某个事件 但是触发事件后,弹出了保存图片。这该怎么办?
小伙看你根骨奇佳,潜力无限,来学PHP伐。
使用img标签微信浏览器会识别,可以用普通p,背景放那张需要长按的图片。
可以试试这样来解决
cssp.img{ position:relative; } p.img:before{ position:absolute; top:0; right:0; bottom:0; left:0; z-index:2; content:"\20"; width:100%; height:100%; display:block; background-color:rgba(255,255,255,0); } p.img>img{ max-width:100%; display:block; }
css
p.img{ position:relative; } p.img:before{ position:absolute; top:0; right:0; bottom:0; left:0; z-index:2; content:"\20"; width:100%; height:100%; display:block; background-color:rgba(255,255,255,0); } p.img>img{ max-width:100%; display:block; }
html <p class="img"><img src="//static.segmentfault.com/build/global/img/logo-w.svg"></p>
html
<p class="img"><img src="//static.segmentfault.com/build/global/img/logo-w.svg"></p>
也可以在longTap里判断 event.target.nodeName == 'IMG'
在时间处理函数里加个 event.preventDefault() 阻止浏览器默认的行为。
event.preventDefault()
window.ontouchstart = function(e) { e.preventDefault(); };
使用img标签微信浏览器会识别,可以用普通p,背景放那张需要长按的图片。
可以试试这样来解决
也可以在longTap里判断 event.target.nodeName == 'IMG'
在时间处理函数里加个
event.preventDefault()
阻止浏览器默认的行为。window.ontouchstart = function(e) { e.preventDefault(); };