window.onbeforeunload not working in dsp

can any help me on this. I am trying to return message while closing window using window.onbeforeunload in my dsp page, but its not happening .