AJAX - The Complete Reference

(avery) #1

454 Part II: Developing an Ajax Library^


around the history. A keystroke catcher could easily be added here to disable the (Alt+left
arrow) key sequence for the whole document:

function disableHistoryKeys(e)
{
var evt = e || window.event;
if (evt.altKey)
{
if (evt.keyCode && (evt.keyCode == 39 || evt.keyCode == 37))
return false;
else if (evt.which && (evt.which == 39 || evt.which == 37))
return false;
}
return true;
}
AjaxTCR.util.event.addWindowLoadEvent(function ()
{ document.onkeydown=disableHistoryKeys;});

Of course, the user can still access the history menu or hit the visible back button, so this
doesn’t do us much good.

To address this, a new window could be spawned containing the Ajaxified application
without the back button showing.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Chapter 9 : Architecture - Launch window to solve back problem</title>
<link rel="stylesheet" href="http://ajaxref.com/ch9/global.css"
type="text/css" media="screen" />
<script type="text/javascript" src="http://ajaxref.com/ch9/ajaxtcr.js"></script>
<script type="text/javascript">function spawnAppWindow()
{
appWindow = window.open("http://ajaxref.com/ch8/photoviewer.html",
"photoviewer","width=1000,height=500");
}
AjaxTCR.util.event.addWindowLoadEvent(function (){$id("launchBtn")
.onclick=spawnAppWindow});
</script>
</head>
<body>
<div class="content">
<h1>App Launcher</h1><hr /><br />
Free download pdf