I want to fire onbeforeunload event for once on my page and then disable it. I tried the following code but it doesn't work. Any ideas about this?

HTML Code:
var counter = 0;
window.onbeforeunload = function() {
	if (counter === 0) {
		return false;
Purpose: That will be used to bust iframe buster.