Reputation: 381
I've been trying around for some time and searched and searched for solutions with no results so far.
The problem:
I have an URL in a webpage that I want to select as a whole to copy it from a mobile browser. For Firefox I'm using a readonly input of type text and with the click event listener I trigger select() on the input. That works like a charm on mobile FF.
For Safari there also is a workaround which even triggers the copy-dialog on click.
With Chrome I could not manage to achieve this.
There is a Chrome issue here which says that selecting from an input wich is readonly does not work (thats still true, tested that).
By using a Label:
<label id="fileLink" type="text" class="link fakeInput" />
, a method to select the text from here and
$('#fileLink').click(function() { markieren(this) });
, I was able to select the url with a click on it. But this will not trigger the copy-dialog. By holding onto the url to copy it, it will only select a part of it and then I have to manually select the whole url to copy it.
I can't imagine, that there is no workaround for this.
To be more clear: for FF I'm using in javascript:
$('#pFileLink').append('<input id="fileLink" type="text" class="link" readonly="readonly" />');
$('#fileLink').click(function() { this.select(); });
$('#fileLink').val(url)
Has anyone an idea how to solve this for mobile chrome?
Upvotes: 3
Views: 292
Reputation: 790
What do you mean with "will not trigger the copy-dialog"? You can't access the clipboard in Chrome so far.
You can alert the link, use a promp or a "modal box" with a input type text (not readonly) with selected text so the user can copy it.
Upvotes: 0