Appendix JS_C_A5

 

Summary

Requirement: Timed activity can be controlled.

Details: Warn the user when a time-limit is about to expire, and provide a mechanism for extending it.

Examples

Correct code

Refer to the JS_C_A5 live demo for a working example.

function sessiontimer()
{
    window.setTimeout(function()
    {
        if(confirm(
            'Your session is about to expire. '    
            + 'Do you need more time?'))
        {
            sessiontimer();
        }
        else
        {
            alert('Your time is up!');
        }
 
    }, 10000);
}
 
sessiontimer();