JS中换行符是\r\n,把服务器端的<%=content%>替换掉换行符、引号转义符等。例如VBS服务器端的话<%=Replace(Replace(Replace(content,vbCrLf,"\r\n"),"'","\'"),"""","\""")%>,我的可能有错,让大家帮你改。

解决方案 »

  1.   

    懒办法
    <div id="pic <%=i%>" onmouseout="closeDiv('aaa')" onmouseover="openDiv('pic <%=i%>','aaa',document.getElementById('content').innerHTML)"
    ……<div id="content" style="display:none">
    <%=content%>
    </div>
      

  2.   

    要确定 <%%>的输出正确,
    可以查看源文件,看下是否输出正的代码。
      

  3.   

    我的是jsp,怎么转换能说具体一下吗
      

  4.   

    我之前 就是这样做的,我是想再我鼠标没有滑过小图层的时候,不会加裁content内容,因为这样占用时间和资源。。我想在滑过小图层的时候才加载内容。。
      

  5.   

    <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
                    };
                }
                
            
                  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>         
      

  6.   

    使用ajavx怎么获取啊,那不更麻烦吗。望指点一下
      

  7.   

    <div id="pic <%=i%>" onmouseout="closeDiv('aaa')" 红色部分有问题,id是不能有空格的
      

  8.   

    var xmlobj;
    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);
    }
      

  9.   

    谢谢。。我也想过用ajax,但是我这个本身有多台服务器,有ajax不容易实现啊,,而且我这是jsp的
      

  10.   

    content=replace(content,"\r"," ") 
    content=replace(content,"\n"," ") 
    content=replace(content,"\r\n"," ") 
    content=replace(content,"\n\r"," ")