How do i differentiate when a page is refreshed event from a page/browser closed event?
Because it seems that the onbeforeunload event is triggered when a page is refreshed and when it's closed, and i didnt want that to happen ?
I don't think it's possible to distinguish between these events. WRT refresh are you talking about the browser button / F5? If so, I can't see how you'd trap this event. If the refresh is via webpage link, you probably could stop the onbeforeunload event before completing the page refresh.
Don't take my view as the gospel truth though.
Here's some code I slapped together to show how to prevent the onbeforeunload:
I have no idea whether this helps at all?