javascript - onbeforeunload function empty fields -
i have function save
needs called on onbeforeunload event. code:
var data = new array(); window.onbeforeunload = save; function save(){ console.log(data); } function update(){ data.push('test'); } setinterval(update, 100);
the data array empty when save method gets called. in field lots of 'test' elements. why empty?
you need return test anything.
function save(){ console.log(data); return "testing console output"; }
this working fine me.
Comments
Post a Comment