日期:2014-05-16  浏览次数:20393 次

定位出现问题,用的都是JS
有这么两个图层,我用JS把JS查询后台得到的结果加到图层里。如果单独是这个的话,没问题
关键是我又加了个小窗口的图层,是JS定时查询后台,得到结果以小窗口形式显示,每当小窗口出来后就会影响到原先的图层,原先的图层好像移动了,位置发生了改变,是不是我的那些属性写得不太对
<div class=div_cont>
<div id="result"></div>
<div id="paging"></div>
</div>


不用细看,就看看那些图层,找了半天,不明白为什么
HTML code
<%@ page language="java" pageEncoding="UTF-8"%>
<%if(request.getParameter("name")==null)
    response.sendRedirect("dl.jsp");
String name=request.getParameter("name");
session.setAttribute("name",name); %>
<html>
<head>
<title>31231</title>
<script type='text/javascript'
    src="${pageContext.request.contextPath}/dwr/engine.js"></script>
<script type='text/javascript'
    src="${pageContext.request.contextPath}/dwr/util.js"></script>
<script type='text/javascript'
    src="${pageContext.request.contextPath}/dwr/interface/searchService2.js"></script>
<script type='text/javascript'
    src="${pageContext.request.contextPath}/dwr/interface/searchService.js"></script>
<style type="text/css">
.div_cont {
    width: 1000px;
    float: left;
    margin: 10px;
}

#result {
    width: 800px;
    float: left;
    margin-top: 5px;
}

#paging {
    width: 800px;
    float: left;
    margin-top: 5px;
}
</style>
<script language="javascript">
    var request;
    var minpage;
    var maxpage;
    var startindex;
    var hasnext;

    function doSearch(type) {
        var result = document.getElementById("result");
        var pagingdiv = document.getElementById('paging');
        result.innerHTML = "";
        pagingdiv.innerHTML = "";

        if (type != 'paging') {
            var startindexinput = document.getElementById('startindex');
            startindexinput.value = "1";
        }

        request = {
            startindex : 1,
            query : ""
        };
        DWRUtil.getValues(request);
        //DWREngine.setAsync(true);
        if (request.query == "") {
            alert("请输入正确的词");
        } else {
            searchService.getSearchResults(request, fillPage);
        }
        //DWREngine.setAsync(false);
    }

    function fillPage(data) {

        //    alert(DWRUtil.toDescriptiveString(data, 2));

        var resultdiv = document.getElementById('result');
        var pagingdiv = document.getElementById('paging');

        resultdiv.innerHTML = "";
        pagingdiv.innerHTML = "";

        if (data.length == 0) {
            resultdiv.innerHTML = "<span>sorry, we can't find what you want...</span>";
            return;
        }

        if (null != data) {

            for ( var i = 0; i < data.length; i++) {
                //alert(data[i].id);
                var results = data[i];
                //alert(results);
                var ele = document.createElement('div');
                ele.setAttribute('id', 'info' + i);
                ele.innerHTML = "<span>loading..</span>";
                resultdiv.appendChild(ele);
                var res = document.getElementById('info' + i);
                //res.innerHTML="<font color=\"#0033CC\">" + title[i] + "</font><br /><a href=\"" + url[i] + "\">"
                res.innerHTML = "<a href=\"" + data[i].url + "\">"
                        + "<font color=\"#0033CC\">" + results.title
                        + "</font></a><br /><font color=\"#008000\">&