This method depends somehow on how you implement your "isLoggedIn" function on the server side.
But let's say you can control cookies and you are setting a cookie LoggedIn=true
when an user is logged in and delete this cookie with the logout function.
Then it's as simple as
if( ! readCookie( 'LoggedIn' ){
alert( "you are not logged in" );
document.location = "/your_login_page.html";
}
where the readCookie
function is taken from here: http://www.quirksmode.org/js/cookies.html#script
The same method can be done with session-ids of cause as long as you delete the session on logout.