我在 iPad 上的 Safari 中遇到了严重问题。新的 contenteditable 功能似乎不适用于 touchmove 事件!代码:
...
<script>
function doNothing(event) { return; }
function initIFrame() {
var iframe=document.getElementById("iframeedit");
iframe.contentWindow.document.designMode="on";
iframe.contentWindow.document.addEventListener("touchmove", doNothing, true);
}
</script>
</head>
<body onload="initIFrame()">
<iframe style="width:500ppx;height:200px" src="content.html" id="iframeedit"></iframe>
...
通过在文档的某处添加 touchmove,可编辑内容在 touchmove 后无法再编辑(按住手指以获取放大镜)。可以设置光标,但不再允许通过屏幕键盘输入。
测试脚本(iPad + iOS5): http: //flyingdog.biz/tests/ipad/test2.html
另一个正在运行的测试脚本:http: //flyingdog.biz/tests/ipad/test1.html
正如您在其他脚本中看到的那样,我在 iFrame 前面放了几行文本 - 非常奇怪!我正在寻找另一种/更好的解决方法,还是我做错了什么?如果没有 touchmove 事件,它可以工作,但我需要它来获得良好的编辑体验。