views:

49

answers:

1

I've got a modal dialog popping up via jQuery, but I would like it to behave like a regular js alert in that a) if you are on another tab it will bring the browser's focus back to the page with the alert and b) an alert sound "ding!" will be played.

Is this possible?

Here is my dialog box:

var $newCandleDialog = $('<div></div>')
        .load('/prodash/dash_access.php?urlInit=candles/getCanStatus.php','it='+newData)
        .dialog({
            autoOpen: false,
            title: 'Active Mode: New Candles!',
            modal: true,
            buttons: {
                "Load new candles": function() {
                    $("#canHint").load('/prodash/dash_access.php?urlInit=candles/getcandles.php','q=0&show=05&strength=00');
                    $( this ).dialog( "close" );    
                },
                Cancel: function() {
                    $( this ).dialog( "close" );
                }
            }
        });
A: 

For focus you can use: this.focus();

For sound please take a look into SoundManager 2 Javascript's library.
Uses Flash where HTML5 is not supported.

Hope it helps!

Frankie
will focus() switch your tabs in the browser?
@user410341 depends on your browser. Hopefully not as no program should ever steal your focus. Even so, some browsers do allow you to steal focus().
Frankie