曾经的经典

[quote]
var xmlHttp;
var dataDiv;
var offsetEl;


//create the XMLHttpRequest object
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} else {
if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
if (!xmlHttp) {
alert("fail to create the XMLHttpRequest object");
}
}


//initialization the div object
function initVars() {
dataDiv = document.getElementById("popup");
dataDiv.style.visibility = "visible";
}



//get the element's value when the mouse over it
function getData(element) {
initVars();
createXMLHttpRequest();
offsetEl = element;
var url = "/PhoneTest/shoppingCart.do?method=getData&pid=" + escape(element.id);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = callBack;
xmlHttp.send(null);
}
function callBack() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
setData(xmlHttp.responseXML);
}
}





//clear the value in the div
function clearData() {
dataDiv.innerHTML = "";
dataDiv.style.width = 0;
dataDiv.style.height = 0;
dataDiv.innerText = "";
dataDiv.style.borderColor = "#FFFFFF";
//dataDiv.style.visibility = "hidden";
}
function hiddenDIV() {
dataDiv.style.visibility = "hidden";
}



//show the div
function showDIV() {
dataDiv.style.visibility = "visible";
}





//show the data on the div
function setData(xml) {
clearData();
pid = xml.getElementsByTagName("pid")[0].firstChild.data;
pinpai_id = xml.getElementsByTagName("pinpaiid")[0].firstChild.data;
var pinpai = xml.getElementsByTagName("pinpai")[0].firstChild.data;
var pattern = xml.getElementsByTagName("pattern")[0].firstChild.data;
var member_price = xml.getElementsByTagName("member_price")[0].firstChild.data;
var basicfunction = xml.getElementsByTagName("basicfunction")[0].firstChild.data;
dataDiv.innerHTML = "<font color=red>" + pinpai + pattern + "</font><br/>";
dataDiv.innerHTML += "<font color=red>\u4f1a\u5458\u4ef7:</font>" + member_price + "\u5143";
dataDiv.innerHTML += "<br/><font color=red>\u57fa\u672c\u529f\u80fd:</font>" + basicfunction;
dataDiv.innerHTML += "<br/><a href='/PhoneTest/eachPhone/eachPhone.jsp?pid=" + pid + "&pinpai_id=" + pinpai_id + "' style='color:red'>\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f>>></a>";
dataDiv.style.left = calculateLeft(offsetEl, "offsetLeft") - 200 + "px";
dataDiv.style.border = "blue 1px solid";
dataDiv.style.borderColor = "#111111";
dataDiv.style.background = "#FFFFFF";
dataDiv.style.top = calculateTop(offsetEl, "offsetTop") + "px";
dataDiv.style.width = "200px";
}


//return the mouseover element moving top
function calculateTop(ele, moveset) {
var offset = 0;
while (ele) {
offset += ele[moveset];
ele = ele.offsetParent;
}
return offset;
}
function calculateLeft(ele, moveset) {
var offset = 0;
while (ele) {
offset += ele[moveset];
ele = ele.offsetParent;
}
return offset;
}

[/quote]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值