Barnaby Norman

Menus and Site Maps

Barnaby Norman Home Page | Site Map | Family Norman Genealogy Site | Contact Me

The function loadMenu() posts the page identifications to the server, which in turn returns a formated side menu with an arrow pointing to the selected page.

Source code for menu.js

function loadMenu(menu, item)
{
    
// Create AJAX object
    
if (window.XMLHttpRequest)
    {
        
// Mozilla version
        
menu_ajax new XMLHttpRequest();
    }
    else if (
window.ActiveXObject)
    {
        
// IE version
        
menu_ajax new ActiveXObject("Microsoft.XMLHTTP");
    }
            
    
// Prepare data to send
    
var sendData menu ";" item
    
var sendData encodeURIComponent(sendData);

    
// Open session and send data
    
menu_ajax.open("POST","/menu/menu.php");
    
menu_ajax.setRequestHeader('Content-Type''application/x-www-form-urlencoded; charset=UTF-8');
    
menu_ajax.send(sendData);

    
// Get data when complete at server end
    
menu_ajax.onreadystatechange=function()
    {
        if (
menu_ajax.readyState==4)
        {
            
document.getElementById('leftLinks').innerHTML menu_ajax.responseText;
        }
    }
}