We are going to edit playlist.jsp. Here is the part we are going to edit:
- Code: Select all
<script type="text/javascript" language="javascript">
var player = null;
var songs = null;
var currentAlbumUrl = null;
var currentStreamUrl = null;
var startPlayer = false;
var repeatEnabled = false;
var slider = null;
function init() {
dwr.engine.setErrorHandler(null);
startTimer();
<c:choose>
<c:when test="${model.player.web}">
createPlayer();
</c:when>
<c:otherwise>
getPlaylist();
</c:otherwise>
</c:choose>
}
we are going to add "window.onbeforeunload = askConfirm;" right under "startTimer();".
Now we are going to add this function:
- Code: Select all
function askConfirm() {
return "Are you sure you want to exit?";
}
Hope this helps!

Note: Some browsers, including Google Chrome have a default message that will appear underneath your custom message, so feel free to remove the quoted text after "return" (and remove the quotes).
This mod is better when many other things are added, and I plan to post the full version of the exit warning mod soon.
On my instance of subsonic, if a song is playing, the warning will come up with the name and artist of the currently playing song.
When playing videos there is a similar warning replaced with the title of the video.
However, when clicking the back link or new window link or changing the time or bitrate, the warnings don't appear.