Javascript ipadhtml中的文本选择
我有一个div,里面有文本。我希望文本在iPad上是可选择的(用于复制/粘贴)。同时,我希望能够处理onclick事件。 这似乎不太合拍。一旦div可点击,它就不可选择 有人知道怎么解决这个问题吗Javascript ipadhtml中的文本选择,javascript,html,ipad,Javascript,Html,Ipad,我有一个div,里面有文本。我希望文本在iPad上是可选择的(用于复制/粘贴)。同时,我希望能够处理onclick事件。 这似乎不太合拍。一旦div可点击,它就不可选择 有人知道怎么解决这个问题吗 <html> <head> <script> function run() { // do some stuff here... } </script> </head> <body> <!-- r
<html>
<head>
<script>
function run() {
// do some stuff here...
}
</script>
</head>
<body>
<!-- removing this onclick makes the div selectable -->
<div onclick="run()">
<p>AAA aaaa aaaa aaaa<p>
<p>bbbbb bbbb BBBBB</p>
<div>
</body>
函数运行(){
//在这里做一些事情。。。
}
AAA aaaa aaaa aaaa
bbbbbbbbbbbbbbbbbbbb
您应该为iOS web交互使用事件处理程序:
// Replace "document" with the element you want it to apply
// to through getElementById("anId")
document.addEventListener("touchstart", run, false);
这将在触摸开始时调用run()
onclick、onmousedown等默认方法在iPhone、ipodtouch和iPad上的行为异常
更多