onmousedown in Firefox vs Chrome in Capacitive devices

时间:2017-03-24 04:51:23

标签: javascript html google-chrome firefox touch

这个问题更具概念性。

当在电容式多点触摸设备中访问具有以下代码的html页面时,
(a)在Chrome浏览器中:识别用户点击/触摸的速度很慢 (b)在Firefox浏览器中:识别用户点击/触摸非常快。

我了解如果要在多点触控设备中使用该页面,我们需要处理TOUCH事件。

但是,这使得下面的代码在Firefox中运行得很快,而在多点触控电容设备中却没有在Chrome中运行。

#action_triggering_element
{
width: 250px; 
height: 250px;
background-color:green;
text-align:center;
vertical-align: middle;
line-height: 250px;
}
<html>
  <head>
    <title>Demo touch vs mouse</title> <!-- Title for the web page -->
  </head>
  <body>
  <!-- Include the jQuery library -->
  <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
  <!-- Include the jQuery Mobile library -->
  <script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>

	<!-- TOUCH event support for 'action_triggering_element' -->
	<!-- <script>		
	$(document).on('tap','#action_triggering_element' , function()   {event.preventDefault();event.stopPropagation();console.log('Tap event recognised!');});
	</script> -->
		
		<!-- HTML element created as 'action_triggering_element' along with support for MOUSE event -->
		<div id="action_triggering_element" onmousedown="event.preventDefault();event.stopPropagation();console.log('Mousedown event recognised!');">
		  <b>Touch/Click here!</b>
		</div>  
  </body>
</html>

0 个答案:

没有答案