javascript - 如何从包含 onclick 事件的文本中删除突出显示?

标签 javascript html internet-explorer windows-phone-8 internet-explorer-10

我正在使用 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>

但是当我单击任何一行时,整行都会像这样被选中。 enter image description here

我想删除这个突出显示。有什么办法可以做到这一点吗?

最佳答案

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/

相关文章:

javascript - 循环浏览图像直到悬停 jquery

javascript - 如何在 lit-element 中实现 lit-element-bootstrap 包

html - 嵌套的div没有填满父div的宽度

javascript - 尝试从 'hover' CSS 过渡转换为类似的 javascript 功能。失败了

javascript - document.title 问题 ie8

html - .net:应用程序在服务器上的 IE8 中丢失样式

javascript - 如何在延迟效果中应用平滑淡入淡出

javascript - Jquery 在提交时验证多个输入

javascript - 无法从通用函数(Angular)获取数组的第一个值

html - 居中 : display table and img with max-width