我遇到了jQuery 1.6.4,iOS 5以及touchstart/touchend事件注册的问题(显然标题中所述).
请使用以下代码:
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="mmpa/jquery-1.6.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var $body = $('body');
$('<button>').html('test jQuery').bind('touchstart', function() { alert('touchstart'); }).appendTo($body);
});
</script>
</head>
<body>
<button ontouchstart="alert('touchstart');">test pure JS</button>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
"纯JS"按钮显示iOS 4.3和iOS 5中的警报,但"jQuery"按钮仅适用于iOS 4.3.在iPad/iPhone模拟器上测试,4.3和5; 还在真正的iPhone 4.3,iPhone 5.0和iPad 5.0上进行了测试.如果我使用一个<input type="button">甚至一个简单<a>而不是一个相同的反应<button>.
我认为这是一个与jQuery相关的问题吗?
我目前正在为我的游戏测试我的设备(三星galaxy S2)上的touchstart功能.我正在编写使用javascript和jquery包装在android中的phonegap下,目前有以下问题:
有人可以告诉我他们是否遇到过与我相似的更多问题.有点不知道是否是硬件或触摸启动问题,我可以解决这个问题.
我的导航控件下方示例Javascript(左,上,下,右触摸开关):
if ('ontouchstart' in document.documentElement) {
var left = document.getElementById('left');
left.addEventListener("touchstart", function(e){
if(controlsPlayerChar == '')
{
return false;
}
var l_oldCell = $('#' + controlsPlayerChar).parent().attr('id');
var l_xy = l_oldCell.split('_');
var l_x = l_xy[0];
var l_y = l_xy[1];
if(l_y == 1)
{
direction = "left";
setCharDynamics(controlsPlayerChar);
return false;
}
var l_newCell = l_x + '_' + (parseInt(l_y) - 1);
// validate if next cell is empty
if($('#' + l_newCell + ':has(".shadow")').val() != undefined
|| $('#' + l_newCell …Run Code Online (Sandbox Code Playgroud) 我们开发了一个安装在安卓平板电脑上的 POS(销售点)中的 Ionic 4 应用程序。
问题是,<ion-button (click)="doSomething">事件通常无法识别,因为用户站在平板电脑前面,平板电脑非常低并且没有发出干净的点击,但是一个非常小的水平移动,离子似乎将其识别为(触摸)移动。这种情况在廉价的三星 Tab A 和三星 Tab S3 上都经常发生。
该按钮实际上会像触摸一样改变它的颜色,但它不会触发。这不会发生在 android 键盘上,所以键盘上的按钮似乎更能容忍小动作。
我们尝试了很多组合,例如
(click) tappable
tap
(click) (touchmove)
(clik) (tap)
(tap)
(click) (touchstart)
(touchmove)
(touchstart)
Run Code Online (Sandbox Code Playgroud)
唯一有效的是最后一个。(自然不能在元素列表中使用,因为它会阻止滚动,但我们可以接受)。
现在我认为这是一个有点肮脏的解决方法。有没有更好的解决方案来解决这个问题,比如配置按钮内移动的容差?(事实上,只要我的手指停留在按钮区域,我就想识别点击,这就是它在角键盘上的工作方式)。
欢迎任何建议。
顺便说一句:我不记得在 Ionic 3 上有这么严重的问题,但我可能是错的。
我有一个简单的矩形锚标签.我用jQuery来回应click,并touchstart与下列事件:
$(document).ready(function() {
$("#button").on("click touchstart", function(e) {
$("#log").append(e.type + "<br/>");
});
});
Run Code Online (Sandbox Code Playgroud)
HTML看起来像这样:
<div id="wrapper">
<a id="button" href="#"> </a>
</div>
<div id="log">Log:<br></div>
Run Code Online (Sandbox Code Playgroud)
CSS很简单:
#wrapper {
padding:50px;
}
#button {
display:block;
width:200px;
height:40px;
text-decoration:none;
color:#333;
background-color:#efefef;
border:0px;
padding:0px;
margin:0px;
}
Run Code Online (Sandbox Code Playgroud)
点击矩形锚点的边缘时,仅click触发事件.当您点击该区域的中心,无论是click和touchstart被解雇.
为什么它click似乎只是用胖指检测触发?有没有办法使这个touchstart活动也适用于肥胖的手指?


我正在使用Cordova为Windows创建一个应用程序,该应用程序严重依赖于诸如touchstart和的触摸事件touchmove。这些事件在android和iOS版本中工作正常,但在Windows版本中未触发。取而代之的是,浏览器尝试通过触摸来滚动页面(注意:我在上调用该event.preventDefault函数,touchstart但该事件甚至不会触发)。
在这种情况下,边缘浏览器的行为与cordova应用程序相同。在边缘,当此标志设置为或应用程序运行正常时,当您导航至about:flags被调用enable touch events时,这是一个选项。我想知道在cordova应用程序中设置此标志是否合理。Always onOnly on when a touchscreen is detected
我想为我的移动网站处理“touchstart”事件。它工作得很好,但现在它会在控制台中导致错误。
我使用 Galaxi S7 Chrome v72.0 浏览器对其进行了测试,并使用chrome://inspect/#devices扩展程序对其进行了检查。
当我尝试触摸时,它会导致:
[干预] 忽略使用 cancelable=false 取消 touchmove 事件的尝试,例如因为滚动正在进行且无法中断。
我认为问题仅适用于 Chrome v72.0 浏览器。
var container = document.getElementById('container'),
fragments = document.createDocumentFragment(),
touchScreen = document.createElement('div');
fragments.appendChild(touchScreen);
container.appendChild(fragments);
var mousedownF = function(evt) {
evt.preventDefault();
/* Do something */
return false;
};
touchScreen.addEventListener('touchstart', mousedownF);
touchScreen.addEventListener('mousedown', mousedownF);
Run Code Online (Sandbox Code Playgroud) 我正在修改toucheventsjs。我在 eclipse 的 logcat 中遇到了这个错误。
document.getElementById("squareBracket").
addEventListener("touchmove", touchHandler, false);
document.getElementById("squareBracket").
addEventListener("touchend", touchHandler, false);
function touchHandler(e) {
if (e.type == "touchstart") {
alert("You touched the screen!");
} else if (e.type == "touchmove") {
// alert(e.changedTouches[0].pageX);
// alert(e.changedTouches[0].pageY);
} else if (e.type == "touchend" || e.type == "touchcancel") {
alert('X :' + e.targetTouches[0].pageX);
alert('Y :' + e.targetTouches[0].pageY);
}
}
Run Code Online (Sandbox Code Playgroud)
如果我删除的注释if中touchmove,坐标弹出。但是,如果被注释了,我的logcat中就会出现错误。
我有一个问题,一直困扰着我好几个小时.我有以下html:
<div id='numbers'><span>+44 (0)845 519 7811<br />+44 (0)118 947 4888</span></div>
Run Code Online (Sandbox Code Playgroud)
我已经应用了以下CSS:
#numbers span {
color:#CCC;
}
Run Code Online (Sandbox Code Playgroud)
我检查了继承,看不出任何问题.这个代码显示在我测试过的每个浏览器上,除了iPad和iPhone上的Safari以外的数据(我可以点击它们,它会问我是否要打电话),但文字是白色的!我玩过,改变了DIV Id,以确保我没有穿越风格,将范围color改为各种类型,没有任何改变.
有没有其他人有这个问题?
(我正在使用带有Jquery的touchstart事件,当<a>点击它时显示并隐藏此DIV .我提到这个,因为它可能导致问题,虽然我看不出如何.)
我需要在iphone菜单中模拟悬停或mouseup/down,我给出了两个例子.
<ul id="main_nav">
<li><a href="http://google.com">google</a></li>
<li><a href="http://yahoo.com">yahoo</a></li>
<li><a href="#">Three</a>
<ul>
<li><a href="#">sub One</a></li>
<li><a href="#">sub Two</a></li>
</ul>
</li>
<li><a href="#">Four</a></li>
</ul>
//bind the touchstart event to the link element
$('li').live('touchstart touchend', function(e){
$(this).toggleClass('btn-sign-up-hover');
//alert('alert');
});
a {
display:block;
line-height:30px;
}
li{
background:#096;
}
.btn-sign-up-hover {
background: #F3F;
}
Run Code Online (Sandbox Code Playgroud)
这在iphone中不起作用,
但以下是工作
//bind the touchstart event to the link element
$('li').live('touchstart', function(e){
$(this).css('background','red');
//alert('alert');
});
$('li').live('touchend', function(e){
$('li').css('background','#096');
//alert('alert');
});
Run Code Online (Sandbox Code Playgroud)
问题是我需要使用toggleClass.
我想在用户向下滚动移动设备页面时禁用touchstart事件.该页面具有各种元素,当您单击切换一个类但我希望当用户向下滑动以向下滚动页面时,将触摸touchstart事件.
JQUERY
$(document).on('touchstart click', '.flip-container ', function(event){
event.preventDefault();
$(this).find('.flipper').toggleClass('hover');
});
Run Code Online (Sandbox Code Playgroud)
任何人都知道如何?谢谢!
我正在Ionic 3中寻找单独的事件处理程序,以开始和结束对移动应用程序上HTML元素的触摸。
我发现了许多相关且已解决的问题,但对于Ionic 3却没有,目前似乎仅支持“点击,按下,平移,滑动,旋转和捏合”(https://ionicframework.com/docs/components/#gestures) 。这些似乎都没有在开始时提供“处理程序”,而只是在结束时提供了“处理程序”。我看到,然后它们确实提供了触摸持续时间(deltaTime)的数据,但是到那时为止,这对我而言毫无用处。
要获得更多背景信息,我想清除的是在第一次触摸某个元素的确切时间里的相关超时,然后查看同一特定元素上的触摸是否在一定时间内(例如250毫秒,以便可以将其评估为“点击”)。
例如这样的事情:
JS:
timeout_1 = setTimeout(function() {
// do something if timeout_1 not cleared by touch start
}, 4000);
touched(event) {
clearTimeout(timeout_1);
touching_x = true
timeout_2 = setTimeout(function() {
touching_x = false
// store event details and do other things if timeout_2 not cleared by touch end
}, 250);
}
touch_ended(event) {
if (touching_x==true) {
clearTimeout(timeout_2);
// store event details and do some other things
}
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<button ion-button type="button" (button_touch_started) = …Run Code Online (Sandbox Code Playgroud) touchstart ×11
javascript ×6
jquery ×6
cordova ×3
html ×3
android ×2
click ×2
angular ×1
button ×1
css ×1
dom-events ×1
ionic3 ×1
ionic4 ×1
ios ×1
ipad ×1
mousedown ×1
toggleclass ×1
touch ×1
windows ×1