Estube viendo este tutorial para crear un menu:
http://sofanaranja.com/2005/08/24/mi...orial-de-ajax/ pero el problema es que el menu que muestra el tutorial es un menu deslizante y el que yo tengo en un menu simple.
Este es el codigo ajax:
Código:
// Vamos a presuponer que el usuario es una persona inteligente...
var isIE = false;
// Creamos una variable para el objeto XMLHttpRequest
var req;
// Creamos una funcion para cargar los datos en nuestro objeto.
// Logicamente, antes tenemos que crear el objeto.
// Vease que la sintaxis varia dependiendo de si usamos un navegador decente
// o Internet Explorer
function cargaXML(url) {
// Primero vamos a ver si la URL es una URL :)
if(url==''){
return;
}
// Usuario inteligente...
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send(null);
// ...y usuario de Internet Explorer Windows
} else if (window.ActiveXObject) {
isIE = true;
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send();
}
}
}
// Funcion que se llama cada vez que se dispara el evento onreadystatechange
// del objeto XMLHttpRequest
function processReqChange(){
var texto = document.getElementById("texto");
if(req.readyState == 4){
texto.innerHTML = req.responseText;
} else {
texto.innerHTML = '<img src="images/loading.gif" align="middle" /> Laddar...';
}
}
Este es el div donde quiero que aparezcan los textos:
Código:
<div id="texto" style="height:209px; margin-left: 5px; width: 295px;">
<p> </p>
<p>We offers web templates and flash templates <br>
as low as $1.5. <br>
"Web templates" and "Flash templates" are royalty
<br>
free no link back required. You are free to use <br>
templates for yourself or your client website. <br>
Our web templates cannot be resold or <br>
re-distributed in any form individually <br>
or as a collection.<br>
Join Now! and start downloading immediately. <br>
Web templates and Flash templates <br>
as low as $1.5 each. Instant download <br>
after the payment.</p>
</div>
Y este es mi codigo del menu en html:
Código:
<table width="119" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/p_08.gif" width=119 height=20></td>
</tr>
<tr>
<td background="images/p_10.gif" height="19" class="topics">
<a href="index.html"><img src="images/spacer.gif" width="10" height="1" border="0">::
Hem</a></td>
</tr>
<tr>
<td><img src="images/p_11.gif" width=119 height=1></td>
</tr>
<tr>
<td background="images/p_12.gif" height="19" class="topics"><a href="001.html"><img src="images/spacer.gif" width="10" height="1" border="0">::
Tjänster</a></td>
</tr>
<tr>
<td><img src="images/p_13.gif" width=119 height=1></td>
</tr>
<tr>
<td><img src="images/p_15.gif" width=119 height=1></td>
</tr>
<tr>
<td background="images/p_16.gif" height="19" class="topics"><a href="#"><img src="images/spacer.gif" width="10" height="1" border="0">::
Portfölj</a></td>
</tr>
<tr>
<td><img src="images/p_17.gif" width=119 height=1></td>
</tr>
<tr>
<td background="images/p_18.gif" height="19" class="topics"><a href="#"><img src="images/spacer.gif" width="10" height="1" border="0">::
Om Mig</a></td>
</tr>
<tr>
<td><img src="images/p_19.gif" width=119 height=1></td>
</tr>
<tr>
<td background="images/p_20.gif" height="18" class="topics"><a href="#"><img src="images/spacer.gif" width="10" height="1" border="0">::
Kontakta Mig</a></td>
</tr>
</table>
Que debo hacer ahora para que al presionar en algun link del menu el texto correspondiente se carge dentro del div "texto"?