I need to isolate user-written code snippets from each other in javascript. For now the funniest thing i can think of is closures:
function executor() {
window.alert('Hello!');
size0 = document.getElementById("load").innerHTML;
window.alert('zero:' + size0);
(function(document){
// document = {"innerHTML":"empty"};
window.alert('Hello again!');
size1 = document.getElementById("load").innerHTML;
window.alert('first:' + size1);
(function(window){
size2 = document.getElementById("load").innerHTML;
window.alert('Hello now!');
window.alert('second:' + size2);
// window.alert('second:' +document.getElementById('load').size());
})("empty");
})("empty");
}
Is there a better and safer way to do this? Can i close prototype
for various things like arrays?