Copy-to-clipboard fix (#4190)

* Copy-to-clipboard fix

target.setSelectionRange(0, target.value.length); does not always seem to be
working. It doesn't work once the text is unselected. Using textarea.select()
function: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/select

Fixes #3965.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>

* Empty commit

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
Ahmet Alp Balkan 2017-06-26 11:12:14 -07:00 committed by Andrew Chen
parent ddb6636f2c
commit d33222a6c3
1 changed files with 2 additions and 2 deletions

View File

@ -25,7 +25,7 @@ function copyCode(elem){
}
target.value = document.getElementById(elem).innerText;
// select the content
target.setSelectionRange(0, target.value.length);
target.select();
// copy the selection
var succeed;
@ -520,4 +520,4 @@ $(function() {
if (!$('#home').length > 0 ) {
$('#hero').addClass('no-sub');
}
});
});