window.onbeforeunload function is not working for me in the salesforce lightning environment. I have a visualforce page styled using Lightning design system, we I view the page in classic the window.onbeforeunload works fine and pops out the standard not saved messagebox when I switch the tab. However, when I switch back to lightning and try the same(change the tab) then its not working.
window.onbeforeunload = function(e) {
return 'changes not saves';
Anyone ever come across this scenario.? Please suggest on what I'm doing wrong here,