Questions comment je retire le contenue d'un dans un element. Jai essayer avec tout les facons que jai vue sur Internet et il en pas une qui marche. J'ai essayer avec innerHTML sa marche pas jaiaussi essayer avec var valueoftherightitem = so_getText(tagget,para); et sa maffiche que aaa Part1 quand ses supposer me donner aaa <h2>Part1</h2>;
Voici le code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/JavaScript">
/**
* XML HTTP REQUEST
*/ var callcontent = "false";
var left = "";
var headfoot = "";
var foot = "";
var biglink = "";
var classea = "";
var classe = "";
var valueofselopt = "";
var myArray=new Array();
var toArray=new Array();
var rwhere=new Array();
var xhr = null;
function getXhr()
{
if(window.XMLHttpRequest) // Firefox et autres
{
xhr = new XMLHttpRequest();
}
else if(window.ActiveXObject){ // Internet Explorer
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
}
else { // XMLHttpRequest non supporté par le navigateur
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
xhr = false;
}
}
function so_getText(obj,where) {
if(obj.textContent) return obj.textContent;
if (obj.nodeType == 3) return obj.data;
var txt = new Array(), i=0;
var append = where.appendChild(obj.childNodes);
while(append[i]) {
txt[txt.length] = append[i];
i++;
}
return txt.join("");
}
function so_clearInnerHTML(obj) {
// perform a shallow clone on obj
nObj = obj.cloneNode(false);
// insert the cloned object into the DOM before the original one
obj.parentNode.insertBefore(nObj,obj);
// remove the original object
obj.parentNode.removeChild(obj);
}
function requestcont(callcontent,where,valueofselopt)
{
if (callcontent.length == 0)
{
callcontent = valueofselopt;
}
else
{
callcontent = callcontent;
}
whereto(where);
function whereto(where)
{
where = where;
return where;
}
getXhr();
// On défini ce quon va faire quand on aura la réponse
xhr.onreadystatechange = function(){
// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
whereto();
if(xhr.readyState == 4 && xhr.status == 200){
//document.getElementById('tmpm').innerHTML = xhr.responseText;
for (i=0;i<xhr.responseXML.getElementsByTagName("nssajax").length; i++) {
var tagget = xhr.responseXML.getElementsByTagName("nssajax")[i];
var idAttr = tagget.getAttributeNode("atrwhere");
var getattr = tagget.getAttribute("atrwhere");
alert(tagget.cloneNode(true));
var vaofattr = idAttr.value;
var para = document.getElementById(vaofattr);
var valueoftherightitem = so_getText(tagget,para);
alert(valueoftherightitem);
document.getElementById(vaofattr).innerHTML = valueoftherightitem;
//para.appendChild(tagget);
}
}
};
adressbase="teste_gig.php?content=";
call=callcontent;
mix=adressbase+call;
xhr.open("GET", mix,true);
xhr.send(null);
}
function block(wi,action)
{
var elementNodeReference = document.getElementById(wi);
if (action == "open")
{
elementNodeReference.className = "blockshow";
}
if (action == "close")
{
elementNodeReference.className = "blocknone";
}
}
function moreless(where) {
var elementNodeReference = document.getElementById(where);
if (elementNodeReference.style.display != "none")
{
elementNodeReference.style.display = "none";
}
else
{
elementNodeReference.style.display = "block";
}
}
function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
// add a zero in front of numbers<10
m=checkTime(m);
s=checkTime(s);
document.getElementById('txt').innerHTML= h+":"+m+":"+s;
t=setTimeout('startTime()',500);
}
function checkTime(i)
{
if (i<10)
{i="0" + i;}
return i;
}
</script>
</head>
<body>
<div>
<a href="#" onclick="requestcont('default','default');">Load It</a>
</div>
<div id="default">
</div>
<div id="part1">
</div>
<div id="part2">
</div>
</body>
</html>