It looks like you're new here. If you want to get involved, click one of these buttons!
<div id="progressbar-container"><div id="progressbar"></div></div>
#progressbar-container { width: 12em; background-color: transparent; border: 1px solid white; border-radius: 4px; } #progressbar { width: 0%; height: 2em; background-color: green; border-radius: 4px; }
function move() { var elem = document.getElementById("progressbar"); var width = 1; var id = setInterval(frame, 100); function frame() { if (width >= 100) { clearInterval(id); } else { width++; elem.style.width = width + '%'; } } }
<<button "Test">><<script>>move();<</script>><</button>>But when I click the button, get an error message that says bad evaluation: move is not defined.
Comments
You either need to make it an auto-global, by making it a static method of the window object, or make it a static method of SugarCube's setup object. If you choose the former, you must be careful as the window object contains various APIs which you do not want to clobber.
On the window object
Add the following to your Story JavaScript: Usage:
On SugarCube's setup object
Add the following to your Story JavaScript: Usage: