Ya te han respondido tu pregunta: si usás ajax la página no se recarga, por lo tanto no se produce un evento onload tras cada petición. La única manera que tenés de reemplazar el dicho evento es reiterando la llamada a la función que ahora llamás con window.onload, con onreadystatechange:
Código:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>test</title>
<script>
function $(id){return document.getElementById(id);}
function http(){
if(window.XMLHttpRequest){
return new XMLHttpRequest();
}else{
try{
return new ActiveXObject('Microsoft.XMLHTTP');
}catch(e){
alert('nop');
return false;
}
}
}
function SetContainerHTML(id_contenedor,responseText){
var mydiv = $(id_contenedor);
mydiv.innerHTML = responseText
}
function cargarPagina(url,contenedorId){
var H=new http();
H.open('get',url+'?'+Math.random(),true);
H.onreadystatechange=function(){
if(H.readyState==4){
SetContainerHTML(contenedorId,H.responseText);
window.onload();
H.onreadystatechange=function(){};
H.abort();
H=null;
}else{
$(contenedorId).innerHTML='cargando...';
}
}
H.send(null);
}
var contador=-1;
window.onload=function(){
$('ll').innerHTML=++contador;
}
</script>
</head>
<body>
<div id="pp"></div>
<div id="ll"></div>
<script>cargarPagina('pagina2.php','pp');</script>
<div onclick="cargarPagina('pagina2.php','pp');" style="border:1px outset #000; text-align:center; line-height:12px; width:100px; cursor:pointer; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:9px">repetir llamada</div>
</body>
</html>