<html> <head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><!-- META http-equiv="Page-Enter" CONTENT="RevealTrans(Duration=4,Transition=6)">--><title>搜索结果显示</title> <link href="search.css" rel="stylesheet" type="text/css"> <script language ="javascript" charset="utf-8"> var $ = function(){ return document.getElementById(arguments[0]) || false; } function getAbsPoint(e){ var x = e.offsetLeft, y = e.offsetTop; while (e = e.offsetParent) { x += e.offsetLeft; y += e.offsetTop; } return { x: x, y: y }; }
<div id="pic <%=i%>" onmouseout="closeDiv('aaa')" onmouseover="openDiv('pic <%=i%>','aaa',document.getElementById('content').innerHTML)"
……<div id="content" style="display:none">
<%=content%>
</div>
可以查看源文件,看下是否输出正的代码。
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><!-- META http-equiv="Page-Enter" CONTENT="RevealTrans(Duration=4,Transition=6)">--><title>搜索结果显示</title>
<link href="search.css" rel="stylesheet" type="text/css">
<script language ="javascript" charset="utf-8">
var $ = function(){
return document.getElementById(arguments[0]) || false;
}
function getAbsPoint(e){
var x = e.offsetLeft, y = e.offsetTop;
while (e = e.offsetParent) {
x += e.offsetLeft;
y += e.offsetTop;
}
return {
x: x,
y: y
};
}
function openDiv(_parent, _id, content){
var parent = $(_parent);
var newDiv = document.createElement("div");
newDiv.id = _id;
newDiv.style.position = "absolute";
newDiv.style.zIndex = "9999";
newDiv.style.width = "300px";
newDiv.style.height = "200px";
newDiv.style.overflow = "scroll";
newDiv.style.background = "url(images/aa.jpg)";
newDiv.style.top = (getAbsPoint(parent).y + parent.offsetHeight) + "px";
newDiv.style.left = (getAbsPoint(parent).x+25) + "px";
newDiv.style.border = "1px solid green";
newDiv.innerHTML = content;//把字符串放到图层里面 document.write(content);
document.body.appendChild(newDiv);
}
function closeDiv(_id){
document.body.removeChild($(_id));
}
</script></head>
<body >
<table border ="0" align ="center" cellpadding="0">
<tr>
<td colspan="110" align="center"><img src="images/logo.jpg" ></td>
</tr>
</table><html:form action ="/SearchAllAction" focus="searchContent" method="post">
<table align="center" width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><html:text property="searchContent" />
<html:submit value="GO!" ></html:submit>
</td>
</tr>
</table>
</html:form>
<table align="right" width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right">查询时间为:<font color="red" size="5"> <strong><%=SearchResultLinkedListUtil.intervalTime %>s</strong></font>
</td>
</tr>
</table><br>
<br>
<img src="images/shuxiangtiao.jpg" align="middle" width="1224" height="20"><table cellpadding="0" cellspacing="0" border="0" width="80%">
<tr>
<td width="85%">
<%
中间处理代码,得到content字符串
%>
<div id="pic<%=i%>" onmouseout="closeDiv('aaa')" onmouseover="openDiv('pic<%=i%>','aaa','<%=content%>')" style="border:1px ;width:20">
<img src="images/icon-float.gif" >
</div>
function cermxlobj(){
if(window.XMLHttpRequest)
xmlobj = new window.XMLHttpRequest();
else
xmlobj = new window.ActiveXObject("Microsoft.XMLHTTP");
}
function openDiv(_parent, _id){
var parent = $(_parent);
cermxlobj();
xmlobj.onreadyStateChange = function(){
if(xmlobj.readyState == 4){
var newDiv = document.createElement("div");
newDiv.id = _id;
newDiv.style.position = "absolute";
newDiv.style.zIndex = "9999";
newDiv.style.width = "300px";
newDiv.style.height = "200px";
newDiv.style.overflow = "scroll";
newDiv.style.background = "url(images/aa.jpg)";
newDiv.style.top = (getAbsPoint(parent).y + parent.offsetHeight) + "px";
newDiv.style.left = (getAbsPoint(parent).x+25) + "px";
newDiv.style.border = "1px solid green";
newDiv.innerHTML = xmlobj.responseText;//将服务器端读取到的文本写入DIV中
document.body.appendChild(newDiv); //BODY下追加一个DIV
}
}
xmlobj.open("get","read_content.asp",true);//read_content.asp文件只须将对应记录的content值输出就行了,但注意编码的问题,前台和后台统一编码方式
xmlobj.send(null);
}
content=replace(content,"\n"," ")
content=replace(content,"\r\n"," ")
content=replace(content,"\n\r"," ")