Link to home
Start Free TrialLog in
Avatar of CAMPzxzxDeathzxzx
CAMPzxzxDeathzxzx

asked on

Trying to access the IOS and Android copy function from JQuery

This works perfectly on a Win desktop but I need this to work on IOS and Android devices.  This is an ASP.Net MVC Razor JQuery environment.


$(function () {
            $('#dt_LiveCoinWallets tbody tr td:first-child').click(function (e) {
                var el = $(this).next().find('input')[0];
                el.select();
                document.execCommand("Copy");
                alert("Copied " + el.value);

            });
        });

Open in new window



<table id="dt_LiveCoinWallets" class="table table-striped table-bordered table-hover table-condensed">
                            <thead>
                                <tr>
                                    <th title="Click to select column">
                                        <h3>Copy</h3>
                                    </th>
                                    <th>
                                        <h3>Your Wallet Address</h3>
                                    </th>
                                </tr>
                            </thead>
                            @foreach (var item in Model)
                            {
                                <tr>
                                    <td>
                                        <Font color="blue">
                                            @Html.DisplayFor(modelItem => item.Currency)
                                        </Font>
                                    </td>
                                    <td>
                                        @{ string s = item.Wallet + memo; }
                                        <input type="text" readonly value=@s  />
                                    </td>
                                </tr>
                            }
                        </table>

Open in new window

Avatar of David S.
David S.
Flag of United States of America image

Try temporarily disabling the readOnly property and then enabling it again after the copy command.

Browsers on iOS place more limitations on execCommand("Copy") than other browsers.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.