Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

iPad: Can't copy & paste in an iFrame when jQuery Mobile is included in the parent #4736

Closed
dhague opened this Issue · 5 comments

6 participants

@dhague

iPad 3rd gen on iOS 5.1.1, using Safari.

Scenario:
An HTML page includes the jQuery Mobile script along with an iFrame. The iFrame contains a HTML form, and the user enters some text into one of the form fields.

Expected behaviour:
User copies text from one field and is able to paste it into another field

Observed behaviour:
The iPad's Select, Copy & Paste buttons all appear as normal - but on clicking Paste, nothing gets pasted.

See http://dhague.github.com/jquery-mobile-ipad-bug/outer.html for a demonstration of the issue.

Source HTML for the issue is at https://github.com/dhague/jquery-mobile-ipad-bug

This is causing a headache for our project in which the user registration form appears in an iFrame floating over the main site - users cannot copy/paste values between fields. (The registration form is served from another host, hence the need to use an iFrame instead of a div.)

@CanD42

I verified this on an iPhone, same behavior there: Pasting isn't possible. It seems that sometimes even editing isn't working properly in the paste field.

@fabylv

i verified this on ipad and iphone 5... however, you can type into second field, copy and paste into first field. interesting issue..
it works without jquery mobile and it works with jquery mobile outside an iframe...

@jari-wiklund

It seems that there is a bug in the way ios(5.1.1) safari handles iframes+copy. Luckily the solution I found is simple and works well. Insert these lines of code in the main html(the one containing the tag):</p> <p>if(navigator.userAgent.match(/iPad/i) != null){//modify as needed<br> document.addEventListener(&quot;copy&quot;, function(evt){<br> evt.clipboardData.setData(&#39;text/plain&#39;, window.frames[0].getSelection().getRangeAt(0));<br> }, false);<br> }</p> <p>The funny thing is that the clipboardData, isn&#39;t overwritten, if the event comes from the main document, it will only be overwritten, if the event comes from the iframe.<br> The issue seems to be fixed in later versions of ios, but i haven&#39;t tested it thoroughly.</p>

@ldeluca

@dhague @jari-wiklund @fabylv There hasn't been any activity on this issue in over a year. We're in the process of cleaning up old issues. Can you confirm whether or not this is still an issue with the latest jQM or if we can go ahead and close? Thanks

@arschmitz
Owner

This is actually something we looked into recently that this is a dup of this is a bug with touch events and iOS there is a workaround which is a shim of jQuery Core .on method @gseguin and i worked on it can be found here https://github.com/gseguin/ios-iframe-touchevents-fix Closing as not a bug in jQuery mobile

@arschmitz arschmitz closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.