Click the picture to appear ban mobile terminal default behavior preview

In the mobile terminal development, some devices have click the img tag,

Pictures presents a preview mode, but we did not add any event to the picture

This is the default behavior of the mobile terminal browser, the solution is as follows:

 

1, add onclick = "return false" on the label img

<img src="a.png" onclick="return false" />

 

2, the background image insertion embodiment of FIG.

background: url(a.png) no-repeat;

 

3, using js event prevents the default behavior

var img = document.getElementById('img');
img.addEventListener('click', function(e){
   e.preventDefault(); 
})

 

Also can be solved using css way:

img{ pointer-events: none; }

However, this approach can lead to failure of the picture click event

If you simply display pictures, but there is no interaction, this method can still ~

Guess you like

Origin www.cnblogs.com/haishen/p/11039770.html