我正在使用 Windows Phone 8.1 的 webView 中显示此 html 代码,我猜它使用 IE 11。
<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
</head>
<body>
<p><font size="4">
<span id="1" onclick=notify(1)>Man this is awkward.</span>
<span id="2" onclick=notify(2)> Why is everyone so quite today.</span>
<span id="3" onclick=notify(3)> Oh please someone talk to me.</span>
<span id="4" onclick=notify(4)> This silence is intimidating.</span>
<br><br><br><br></font></p><style>
body {
-webkit-user-select: none;
-moz-user-select: -moz-none;
-ms-user-select: none;
user-select: none;
}
</style><script>
function notify(val)
{
window.external.notify(val.toString());
}
</script></body></html>
但是当我单击任何一行时,整行都会像这样被选中。
我想删除这个突出显示。有什么办法可以做到这一点吗?
最佳答案
CSS
outline-style: none;
-webkit-touch-callout: none;
-webkit-tap-highlight-color: rgba(0,0,0,0);
JavaScript
document.addEventListener("touchstart", function(){}, true);
touchstart 的作用:
$('body').live(
'touchstart',
function(e){
if(e.target.localName != 'select'){
e.preventDefault();
}
}
如果这不起作用,请检查 this 。希望有帮助。
关于javascript - 如何从包含 onclick 事件的文本中删除突出显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25050690/