问题描述
我正在尝试调试代码。在Chrome中触摸时,以下代码可以“ console.log”消息,但在Safari中没有任何打印出的消息。有什么建议吗?
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
document.addEventListener('touchstart',function(e) {
e = e || window.event;
var target = e.target || e.srcElement,text = target.textContent || target.innerText;
console.log(target,text);
},false);
</script>
</body>
</html>
解决方法
当前,dekstop Safari不支持touch API。
您可以查看兼容性表on MDN或使用caniuse.com