Touch events are not triggered on video tags on sa

2019-03-18 13:35发布

问题:

I want to prevent the scrolling on a safari web page for iphone by binding the preventDefault method on the document element of the DOM, and it works on every elements but the video tag.

document.addEventListener("touchmove", function(e){e.preventdefault();}, false);

I've tried attaching the event to the video tags, but it seems as if nothing is attached or the events are simply not triggered.

回答1:

In my test, when ommiting the "controls" attribute of the video you can get the events....

By example....

<video src="http://192.168.1.53/videoTester/Cuatro.mp4" id="player" width="100%" height="100%" x-webkit-airplay="allow" ></video>

Then put a div in top... and it works for me....