3

I know we can use AJAX to change page area so the page is not closed (then audio will not stop), but what if I pressed the refresh button? I have Googled a lot but didn't find a solution.

This is possible, because Jamendo has implemented this feature (Even in the refreshing process, the music continues playing).

1
  • What is Jamendo? It sounds like this question is a plant or plug, promoting him or it, or he's actually done this, in which case it sounds like what he's done is a hack, along the lines of hiding a second window (not recommended). You said it's possible, please give more information on that.
    – id.ot
    Commented Jul 8, 2014 at 7:12

1 Answer 1

1

We can prevent the refresh of the page using the F5 button using Javascript.

if ((e.which || e.keyCode) == 116) e.preventDefault();

[update] The above works great but regarding the browser refresh button and CTRL + R I've just confirmed the following will force a pop-up to the user to confirm they want to leave.

window.onbeforeunload = function () {return false;}

Why not just use AJAX?

1
  • Thanks for answering. Yes I have used AJAX when navigating pages, but client asked me to keep the player running even refreshing the page..
    – Mark Ma
    Commented Jul 8, 2014 at 7:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.