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

 
    • pumpkinlll a dit :...
    • Utilisateur
    • 11 nov. 2008, 22h27m

    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 (?)

    Modifié par pumpkinlll le 13 nov. 2008, 1h28m
    • pumpkinlll a dit :...
    • Utilisateur
    • 12 nov. 2008, 23h24m
    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

    • _Tarkus_ a dit :...
    • Utilisateur
    • 14 nov. 2008, 16h51m
    Cool idea. I've accidentally closed the radio tab before, so this should come in handy.

    • snyde1 a dit :...
    • Abonné
    • 14 nov. 2008, 21h36m

    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.
    • pumpkinlll a dit :...
    • Utilisateur
    • 15 nov. 2008, 0h02m

    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 a dit :...
    • Utilisateur
    • 17 nov. 2008, 20h09m
    Added.

    • pumpkinlll a dit :...
    • Utilisateur
    • 17 nov. 2008, 23h33m
    thanks!

Les utilisateurs anonymes ne peuvent pas poster de messages. Merci de vous connecter ou de créer un compte pour pouvoir intervenir dans les forums.