Note that there are some explanatory texts on larger screens.

plurals
  1. POText selection bug in Mobile Safari with iframes and ontouchstart
    primarykey
    data
    text
    <p>In my web app, I have iframes at varying z-indices. I am detecting <code>touchstart</code> events on some elements in the iframes. However, if I have a text input field overlapping an element capturing <code>touchstart</code>, the input field starts behaving erratically: tapping a second time in the field un-focuses it, you are unable to select any text, but you are able to type in the text field.</p> <p>It appears that the only solution might be to stop capturing <code>touchstart</code> events on the background frame. I'd prefer a solution like a transparent <code>div</code> to capture the events as an intermediary, but I haven't yet gotten that working. Are there other workarounds?</p> <p>Sample page is at <a href="http://jsfiddle.net/dahjelle/DvpQm/">jsfiddle</a>, but here's the code:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;style type='text/css'&gt; iframe { position:absolute; } #background { border: solid 3px red; z-index:1; width: 20em; height: 20em; } #foreground, #foreground2 { border: solid 2px yellow; z-index:2; top: 15em; height: 5em; } #foreground2 { top: 22em; } &lt;/style&gt; &lt;script type='text/javascript'&gt; window.onload=function(){ document.getElementById("foreground").contentDocument.write("&lt;input type='text' value='text'/&gt;&lt;input type='text'/&gt;"); document.getElementById("foreground2").contentDocument.write("&lt;input type='text' value='text'/&gt;&lt;input type='text'/&gt;"); document.getElementById("background").addEventListener("touchstart", function() { console.log("touch"); }); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;iframe id=background&gt;&lt;/iframe&gt; &lt;iframe id=foreground&gt;&lt;/iframe&gt; &lt;iframe id=foreground2&gt;&lt;/iframe&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload