Johannes Thorén wrote:But the method still runs, and if i change it to onLoad or onload, gives the same result
The method runs inline,
not as the unload handler.
And just because something works, doesn't make it right. Use
unload. The browsers are really lenient about errors, but that doesn't mean that errors should be purposefully made!