JavaScript is returning the error: Uncaught TypeError: clickerLink.select is not a function.
I'm trying to make a button copy a certain string.
<button onclick="myFunction()">copy</button>
\
function myFunction(){
let someLink = "loadstring(game:HttpGet('https://raw.githubusercontent.com/JohnWickey/roblox-exploits/main/clickerMadness/main.lua'))()";
someLink.select();
someLink.setSelectionRange(0, 999999); // For mobile devices, if somehow there's an executor for Android or maybe even iOS.
navigator.clipboard.writeText(someLink.value)
}
Does anyone have an answer? Sorry for the inconvenience, I'm new to programming.
CodePudding user response:
if you see your console says that :
Uncaught TypeError: someLink.select is not a function
so I changed your function a little and it works :
function myFunction(){
let someLink = "loadstring(game:HttpGet('https://raw.githubusercontent.com/JohnWickey/roblox-exploits/main/clickerMadness/main.lua'))()";
// someLink.select();
// someLink.setSelectionRange(0, 999999); // For mobile devices, if somehow there's an executor for Android or maybe even iOS.
someLink = someLink.substring(0, 999999);
navigator.clipboard.writeText(someLink)
}
CodePudding user response:
This has worked for me previously, give it a go :)
function copy(el) {
var body = document.body,
range, sel;
if (document.createRange && window.getSelection) {
range = document.createRange();
sel = window.getSelection();
sel.removeAllRanges();
range.selectNodeContents(el);
sel.addRange(range);
}
document.execCommand("Copy");
}