I can't execute this code in console, I want to make a onclick button to open an iframe but when I paste it on console, it says "Uncaught SyntaxError: Unexpected token ';'", any help? thanks!
document.getElementsByClassName("search-bar hp")[0].innerHTML = ("<button class=\'btn btn-primary btn-sm\' onclick=\'AbsenKuy()\'style=\'background-color:#000000;color:white;\'><span class=\'fa fa-bug\'> Auto Absensi</span></button>";
function AbsenKuy() {
document.getElementsByClassName("post-topbar")[0].innerHTML = "<iframe width=\'150 height=\'100\' src='http://elearning-man2kotabogor.sch.id/studentkelas/absensi/MTEyNUtaWQ==/U0VOQlVEX1hJX0tJTUlBX0FZRQ==/MTEyNQ=='></iframe>";
};
document.getElementsByClassName("search-bar hp")[0].innerHTML = ("<button class=\'btn btn-primary btn-sm\' onclick=\'AbsenKuy()\'style=\'background-color:#000000;color:white;\'><span class=\'fa fa-bug\'> Auto Absensi</span></button>";
function AbsenKuy() {
document.getElementsByClassName("post-topbar")[0].innerHTML = "<iframe width=\'150 height=\'100\' src='http://elearning-man2kotabogor.sch.id/studentkelas/absensi/MTEyNUtaWQ==/U0VOQlVEX1hJX0tJTUlBX0FZRQ==/MTEyNQ=='></iframe>";
};
The problem is you have missed some closing brackets in the script.
document.getElementsByClassName("search-bar hp")[0] = ("<button class=\'btn btn-primary btn-sm\' onclick=\'AbsenKuy()\'style=\'background-color:#000000;color:white;\'><span class=\'fa fa-bug\'> Auto Absensi</span></button>");
function AbsenKuy() {
document.getElementsByClassName("post-topbar")[0].innerHTML = "<iframe width=\'150 height=\'100\' src='http://elearning-man2kotabogor.sch.id/studentkelas/absensi/MTEyNUtaWQ==/U0VOQlVEX1hJX0tJTUlBX0FZRQ==/MTEyNQ=='></iframe>"
};
document.getElementsByClassName("search-bar hp")[0] = ("<button class=\'btn btn-primary btn-sm\' onclick=\'AbsenKuy()\'style=\'background-color:#000000;color:white;\'><span class=\'fa fa-bug\'> Auto Absensi</span></button>");
function AbsenKuy() {
document.getElementsByClassName("post-topbar")[0].innerHTML = "<iframe width=\'150 height=\'100\' src='http://elearning-man2kotabogor.sch.id/studentkelas/absensi/MTEyNUtaWQ==/U0VOQlVEX1hJX0tJTUlBX0FZRQ==/MTEyNQ=='></iframe>"
};
This modified code will prevent that error. All the best.