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:
committed by
Andrew Chen
parent
ddb6636f2c
commit
d33222a6c3
+2
-2
@@ -25,7 +25,7 @@ function copyCode(elem){
|
|||||||
}
|
}
|
||||||
target.value = document.getElementById(elem).innerText;
|
target.value = document.getElementById(elem).innerText;
|
||||||
// select the content
|
// select the content
|
||||||
target.setSelectionRange(0, target.value.length);
|
target.select();
|
||||||
|
|
||||||
// copy the selection
|
// copy the selection
|
||||||
var succeed;
|
var succeed;
|
||||||
@@ -520,4 +520,4 @@ $(function() {
|
|||||||
if (!$('#home').length > 0 ) {
|
if (!$('#home').length > 0 ) {
|
||||||
$('#hero').addClass('no-sub');
|
$('#hero').addClass('no-sub');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user