Pregunta

Junk characters are copied to the clipboard on iOS when doing a long-hold/copy on the following html element:

<input type="text" value="inputValue" ng-readonly="true" name="externalInput" readonly="readonly" />

Output:

{\rtf1\ansi\ansicpg1252
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;\red85\green85\blue102;\red255\green255\blue255;}
\deftab720
\pard\pardeftab720\sl400\partightenfactor0

\f0\fs28 \cf2 \cb3 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 inputValue}

How can I stop all of that style info being copied? This only seems to happen on mobile safari.

¿Fue útil?

Solución

Turns out that iOS doesn't like you selecting the text of a readonly="readonly" input. To work around this I change the input to normal (editable) if the user agent is appleios.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top