Monday, June 27, 2011

Javascript

var loadingHtml = "

\"Loading...\"
";

function GetAsynchronousData(url, strDivName, chkLoader) {

//Place Loading HTML
document.getElementById(strDivName).innerHTML = loadingHtml;
document.getElementById(strDivName).style.visibility = "visible";

if (chkLoader) {
if (document.getElementById(strDivName).innerHTML.indexOf('moreLoader.gif') < 0) {
return;
}
}

InitXmlHttpRequest();

var handleStateChanged = function() {
if (xmlhttp.readyState == 4) { // 4 = "loaded"
if (xmlhttp.status == 200) { // 200 = OK
try {
//alert("message from server : " + xmlhttp.responseText);
document.getElementById(strDivName).innerHTML = xmlhttp.responseText;
}
catch (e) {
}
}
else {
//alert("Problem retrieving XML data");
}
}
};

if (xmlhttp != null) {
xmlhttp.onreadystatechange = handleStateChanged;
xmlhttp.open("GET", url, true);
xmlhttp.send(null);
}
else {
//alert("Your browser does not support XMLHTTP.");
}
}



var xmlhttp;

function InitXmlHttpRequest() {

xmlhttp = null;
if (window.XMLHttpRequest) {
// code for all new browsers
xmlhttp = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
// code for IE5 and IE6
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}

Tuesday, August 17, 2010

Popup

function PopupCenter(pageURL, title, w, h) {
var left = (screen.width / 2) - (w / 2);
var top = (screen.height / 2) - (h / 2);
var targetWin = window.open(pageURL, title, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=' + w + ',height=' + h + ',top=' + top + ',left=' + left + ',modal=1');
return false;
}