Hola,
el problema que tengo es que no consigo abrir un html desde javascript usando la funcion "cargar". Quiero que se abra el index donde esta el menu y luego se añada debajo la pagina que se pulse en el menu. Para simplificarlo dejo un ejemplo sencillo que tampoco funciona:
HTML
<!DOCTYPE html>
<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script src = "./js/libCapas.js"></script> 
    </head>
    <body onload="Cargar('inicio.html','cuerpo')">
        <div>
            <table>
                <tr>
                    <td><a href="#" onclick="Cargar('inicio.html','cuerpo')">Inicio</a></td>
                    <td><a href="#" onclick="Cargar('iniciar_sesion.html','cuerpo')">Iniciar Sesion</a></td>
                    
                </tr>
            
            </table>
        </div>
        <div id="cuerpo"></div>
    </body>
</html>
HTML
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
    	<table>
    	<tr>
        <div>TODO write content</div>
        </tr>
     </table>
    </body>
</html>
javascript
function invokeScript(divid)
{
	var scriptObj = divid.getElementsByTagName("SCRIPT");
	var len = scriptObj.length;
	for(var i=0; i<len; i++)
	{
		var scriptText = scriptObj[i].text;
		var scriptFile = scriptObj[i].src;
		var scriptTag = document.createElement("SCRIPT");
		if ((scriptFile != null) && (scriptFile != "")){
			scriptTag.src = scriptFile;
		}
		scriptTag.text = scriptText;
		if (!document.getElementsByTagName("HEAD")[0]) {
			document.createElement("HEAD").appendChild(scriptTag);
		}
		else {
			document.getElementsByTagName("HEAD")[0].appendChild(scriptTag);
		}
	}
}
                        
function nuevaConexion()
{
	var xmlhttp=false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
	{
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch (E)
		{ 
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined')
	{
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp; 
}
function Cargar(url, capa)
{
	var contenido = document.getElementById(capa);
	var conexion = nuevaConexion();
	conexion.open("GET", url, true);
	conexion.onreadystatechange=function()
	{ 
		if(conexion.readyState == 4)
		{
			contenido.innerHTML = conexion.responseText;
			invokeScript(document.getElementById(capa));
		}
	}
	conexion.send(null);                               
} 
                                                
function CargarForm(url, capa, valores)
{
	var contenido = document.getElementById(capa);
	var conexion = nuevaConexion();
	conexion.open("POST", url, true);
	conexion.onreadystatechange=function()
		{ 
			if(conexion.readyState == 4)
			{
				contenido.innerHTML = conexion.responseText;
				invokeScript(document.getElementById(capa));
			}
		};
	conexion.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	conexion.send(valores);
} 
function ProcesarForm(formulario, url, capa)
{
	var valores="";
	for (i=0; i<formulario.elements.length;i++)
	{
		var nombre = formulario.elements[i].name;
		if (nombre!="")
		{
			if (!((formulario.elements[i].type == "radio") && (!formulario.elements[i].checked)))
			{
				valores += formulario.elements[i].name + "=";
				valores += formulario.elements[i].value + "&";	
			}
		}
	}
	CargarForm(url, capa, valores);
}
			
function cargaInicial()
{                            
	Cargar('menu.html','menu');
	Cargar('inicial.html','capa1');
}
Si alguien me puede decir como consigo cargar el segundo html debajo del primero, usando ese javascript
Gracias.