ipad input in iframe

2019-02-13 14:24发布

问题:

I have one page have iframe, there are several text input in the iframe, and input wrap in div. the div listen the touchstart event. here is the demo page: 1) index.html

<body >
<iframe width="950px" height="650px" src="http://192.168.100.14/demo/test.html">
</body>

2)test.html

<body>

<div id="test" >

<input name="name" id="name" /><input name="age" id="age"/>

</div>

<script>

var test = document.getElementById("test");

test.addEventListener('touchstart', function(){}, false);

</script>

</body>

the problem is: 1: the keyboard will dismiss and show between the click event in input element. this will occur even in same input. 2: the copy and paste and select text was not occur in input element when finger press the input.

But if don't listen the div touchstart event or the test.html not in iframe , these won't occur. I search several days but can't find answer. can someone help? Thanks.