?? tooltip.htm
字號:
<html>
<head>
<title>工具提示</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
</head>
<script language="javascript">
//定義一個變量用于存放XMLHttpRequest對象
var xmlHttp;
//記錄事件發生時的鼠標位置
var x,y;
//該函數用于創建一個XMLHttpRequest對象
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
//這是一個通過AJAX取得提示信息的方法
function over(index){
//記錄事件發生時的鼠標位置
x = event.clientX;
y = event.clientY;
//創建一個XMLHttpRequest對象
createXMLHttpRequest();
//將狀態觸發器綁定到一個函數
xmlHttp.onreadystatechange = processor;
//這里建立一個對服務器的調用
xmlHttp.open("GET", "CreateTip?index="+index);
//發送請求
xmlHttp.send(null);
}
//處理從服務器返回的XML文檔
function processor() {
//定義一個變量用于存放從服務器返回的響應結果
var result;
if(xmlHttp.readyState == 4) { //如果響應完成
if(xmlHttp.status == 200) {//如果返回成功
//取出服務器返回的XML文檔的所有shop標簽的子節點
result = xmlHttp.responseXML.getElementsByTagName("shop");
//顯示工具提示
document.all.tip.style.display = "block";
//顯示工具提示的起始坐標
document.all.tip.style.top = y;
document.all.tip.style.left = x+10;
document.all.photo.src = result[0].childNodes[2].firstChild.nodeValue;
document.all.tipTable.rows[1].cells[0].innerHTML="商品名稱:"+result[0].childNodes[0].firstChild.nodeValue;
document.all.tipTable.rows[2].cells[0].innerHTML="商品價格:"+result[0].childNodes[1].firstChild.nodeValue;
}
}
}
function out(){
document.all.tip.style.display = "none";
}
</script>
<body>
<h2>工具提示</h2><br>
<hr>
<a href="#" onmouseover="over(0)" onmouseout="out()">商品一</a><br><br>
<a href="#" onmouseover="over(1)" onmouseout="out()">商品二</a><br><br>
<a href="#" onmouseover="over(2)" onmouseout="out()">商品三</a><br><br>
<div id="tip" style="position:absolute;display:none;border:1px;border-style:solid;">
<TABLE id="tipTable" border="0" bgcolor="#ffffee">
<TR align="center">
<TD><img id="photo" src="" height="80" width="80"></TD>
</TR>
<TR>
<TD></TD>
</TR>
<TR>
<TD></TD>
</TR>
</TABLE>
</div>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -