Search code examples
javascriptlinespaceonbeforeunload

Make new line in window.onbeforeunload?


I was looking and was not able to find out how to make a new line in the window.onbeforeunload in Javascript, can any help me out? I am sorry if this have already been posted, but have been looking for some time now and found nothing.


Solution

  • Use \n:

    window.onbeforeunload = function() {  
        return "I have\nNewlines!";
    }
    

    jsFiddle Demo (right click the Output pane and select > Reload Frame)