1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
function spartooGoURL(url) {
if (window.widget) {
widget.openURL(url);
return false;
} else {
return true;
}
}
function addClickEvent(node) {
var aNodes = new Array();
aNodes = node.getElementsByTagName("a");
for (var i = 0; i < aNodes.length; i++) {
url = aNodes[i].getAttribute("href");
aNodes[i].onclick = function() {
return spartooGoURL(this.href);
}
}
}
function sendData(div, data, page, method) {
if (document.all && !window.opera) {
var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
} else {
var XhrObj = new XMLHttpRequest();
}
var content = document.getElementById(div);
if (method == "GET") {
if (data == 'null' || data=='' || data==null) {
XhrObj.open("GET", page);
} else {
XhrObj.open("GET", page+"?"+data);
}
} else if (method == "POST") {
XhrObj.open("POST", page, true);
}
XhrObj.onreadystatechange = function() {
if (XhrObj.readyState == 4 && XhrObj.status == 200) {
content.innerHTML = XhrObj.responseText ;
addClickEvent(content);
scrollArea.refresh();
}
}
if (method == "GET") {
XhrObj.send(null);
} else if (method == "POST") {
XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
XhrObj.send(data);
}
}
sendData('content','',serverPage+'&news1=1&news2=1&news3=1' ,'GET'); |
Partager