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:
parent
ddb6636f2c
commit
d33222a6c3
|
|
@ -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');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue