有很多类似的帖子,但没有什么适合我的需要.所以我被迫创建一个帖子.
名称列表显示在jsp页面上.当您将鼠标悬停在某个名称上时,我会进行一次ajax调用,以便在工具提示弹出窗口中显示该名称的详细信息.
用户将使用IE8.在IE8中执行这个简单的操作需要大约5秒钟,因为在Firefox和Chrome中它会立即发生.
我还注意到,当显示的名称数量增加或减少时,IE8中的响应时间也相同.
如何在IE8中加快速度?
jsp页面
<td onm ouSEOver ="showDetails('${origin }')">
<a href="#"><c:out value="${origin}"></c:out><span id="info"></span></a>
</td>
javascript函数
function showDetails(stop){
var xmlHttpRequest;
if(window.XMLHttpRequest){
xmlHttpRequest = new XMLHttpRequest();
}else{
xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttpRequest.onreadystatechange=function(){
if(xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200){
document.getElementById("info").innerHTML = xmlHttpRequest.responseText;
}
}
xmlHttpRequest.open("GET", "showStopsInfoPopup.do?stop="+stop, true);
xmlHttpRequest.send();
}
解决方法:
试试这个.
function showDetails(stop){
var t1 = new Date().getTime();
var xmlHttpRequest;
if(window.XMLHttpRequest){
xmlHttpRequest = new XMLHttpRequest();
}else{
xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttpRequest.onreadystatechange=function(){
if(xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200){
alert("Call took " + (new Date().getTime() - t1) + " milliseconds");
document.getElementById("info").innerHTML = xmlHttpRequest.responseText;
}
}
xmlHttpRequest.open("GET", "showStopsInfoPopup.do?stop="+stop, true);
xmlHttpRequest.send();
}
您可能会看到调用同样快,但是后续呈现的响应在IE8中很慢.
如果你确认了,那么问题是关于responseText中的内容.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。