window.onbeforeunload = function () {return false;}
This disables leaving the page unless the user confirms, not only refresh, so you'll have to code this yourself to get it to work.
You never said what you were doing with it so I left it at that.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…