javascript - Making a function with a random name and calling it later -


so i'm trying make function have random name generated on page load, i'm having problems calling method later. got far:

 var methodname = math.floor(math.random()*1000001);     window[methodname] = function(){      alert("it works!");  }  window.onload = function start() {      methodname();  } 

but i'm having problems calling it, since methodname(); random number. how call methodname() function?

you can reference property same way set it:

window[methodname](); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -