Are you sure you want to navigate away from this page?

 
  • Are you sure you want to navigate away from this page?

    Hi all,
    Today I made my first steps with greasemonkey and made a 1 (big!) line script.
    Please tell me if it did already exist!!

    What it does: when listening to a radio (in the www.last.fm/listen/* domain), if you try to close the tab/window or to click a link, you get a Box saying:
    Are you sure you want to navigate away from this page?
    Currently playing: Metallica - Enter Sandman
    Press OK to continue, or Cancel to stay on this page


    that avoids some frustration.
    its here: http://userscripts.org/scripts/show/36832
    and it has just one line :-/

    Obviously I would like to make it work for last.fm/music/ and last.fm/user/ etc, i.e. in the "playlist" mode of the flash player rather than the "radio" mode.
    Why I did not do it? In radio mode, the title of the window changes when a track is played, and it's easy for the script to know whether something is being played.
    In playlist mode... the script has to talk with the flash player, I don't even know if it's possible.

    please help if you have any idea as to how to do that!
    thanks
    pklll

    NB: it uses the "onBeforeUnload" event, which I think is not real javascript but supported by main browsers such as Firefox, IE, Opera (?), Safari (?)

    Edited by pumpkinlll on 13 Nov 2008, 01:28
  • I updated the script, it now adds a checkbox under the flashplayer on any page.
    If this box is checked, a confirmation will be asked before navigating away:

    http://userscripts.org/scripts/show/36832

  • Cool idea. I've accidentally closed the radio tab before, so this should come in handy.

    • snyde1 said...
    • Subscriber
    • 14 Nov 2008, 21:36

    Re: Are you sure you want to navigate away from this page?

    pumpkinlll said:
    NB: it uses the "onBeforeUnload" event, which I think is not real javascript but supported by main browsers such as Firefox, IE, Opera (?), Safari (?)
    This event is not supported by Opera.

    Improve your view of Last.fm - add some User Scripts.
    Did I hear that right? Mondegreens - for the misheard word. Like Odds? Can't get better than Even Odds!

    Speak your truth quietly and clearly; and listen to others, even to the dull and the ignorant; they too have their story.
  • Re: Re: Are you sure you want to navigate away from this page?

    snyde1 said:
    pumpkinlll said:
    NB: it uses the "onBeforeUnload" event, which I think is not real javascript but supported by main browsers such as Firefox, IE, Opera (?), Safari (?)
    This event is not supported by Opera.


    ahm thanks for the precision. I wasn't sure at all, that's why I put the "?" =)

    • marshee said...
    • User
    • 17 Nov 2008, 20:09
    Added.

  • thanks!

Anonymous users may not post messages. Please log in or create an account to post in the forums.