I am writing a UserScript, everything works fine until now, just when I click on a button I applied an onClick Attribute on, the console keeps telling me Uncaught ReferenceError: SB_Change is not defined
and the function SB_Change(what)
will not be executed.
Code:
window.addEventListener('load', function() {
var but1 = document.createElement("BUTTON");
var t1=document.createTextNode(" + ");
but1.style.width = "16px";
but1.style.height = "16px";
but1.appendChild(t1);
but1.setAttribute('onclick','SB_Change("+")');
// -
var but2 = document.createElement("BUTTON");
var t2=document.createTextNode(" - ");
but2.appendChild(t2);
but2.style.width = "16px";
but2.style.height = "16px";
but2.setAttribute('onclick','SB_Change("-")');
// -
var SB_text = document.getElementById("shoutbox").getElementsByTagName("h3")[0];
SB_text.innerHTML = "Shoutbox ";
SB_text.appendChild(but1);
SB_text.appendChild(but2);
function SB_Change(type){
var H = document.getElementById("sbPosts").maxHeight;
switch(type){
case "+":
H = "800px";
break;
case "-":
H = "400px";
break;
}
}
}, false);