我真的不知道我哪里有错误
当DIV ID =“livelog”悬停时,我需要在DIV中停止滚动。请帮忙。
HTML
<HTML>
<HEAD>
<script src="jquery.js" type="text/javascript" charset="utf-8"></script>
CSS
<style type="text/css">
#livelog {
height:500px;
max-width:1500px;
overflow-y:scroll;
list-style:none;
text-align:left;
margin:5px auto 15px;
border:1px dotted #AAA;
background-color:#FAFAFA;
color:#666;
font-family: "Courier New",monospace
}
</style>
脚本
// beginn parameters
var maxloglines = 200;
var pollintervall = 1000;
var aniduration = 10;
// end parameters - do not change things below
var parameters = "?lasttime=0";
var lastdebuglevel = 0;
var stoppoll = 0;
脚本 - DIV的功能:悬停
window.onload=function(){
$("#livelog").mouseover( function () {
$('#livelog').stop(true);
$(this).css('background', 'yellow')
});
$("#livelog").mouseout( function () {
$("#livelog").animate({ scrollTop: $("#livelog").prop("scrollHeight") }, aniduration);
$(this).css('background', '#FAFAFA')
});
}
脚本 - 延续
// manage the delivered data / loglines
function addLog(data) {
var lines = data.split('\n');
$.each(lines, function(key, line) {
var parts = line.split('|');
if(parts[2]){
if(parts[0] == 'debug') {
setDebuglevel(parts);
} else if (parts[0] == 'message') {
if (parts[1] == 'nolog'){
stoppoll = 1;
$("#livelogdata").append('<li>' + parts[2] + '</li>\n');
} else if (parts[1] == 'nodebug'){
$("debugmenu").remove()
}
} else {
$("#livelogdata").append('<li class="' + parts[1] + '">' + parts[2] + '</li>\n');
parameters = "?lasttime=" + parts[0];
if ($("#livelogdata li").length >= maxloglines) { $("#livelogdata li").eq(0).remove(); }
$("#livelog").animate({ scrollTop: $("#livelog").prop("scrollHeight") }, aniduration); // for scroll bottom
}
}
});
}
// polling
function waitForMsg(){
$.ajax({
type: "GET",
url: "logpoll.html" + parameters,
async: true,
cache: false,
success: function(data){
addLog(data);
if(!stoppoll) {
setTimeout("waitForMsg()", pollintervall);
}
},
error: function(XMLHttpRequest,textStatus,errorThrown) {
setTimeout("waitForMsg()", 15000);
}
});
}
// start polling
$(document).ready(function() { waitForMsg(); });
</script>
</HEAD>
HTML BODY
<BODY>
<DIV ID="wrapper"> <!-- Start wrapper -->
<DIV ID="content"> <!-- Start content -->
<H3>Live Log</H3><br>
<DIV ID="livelog">
<UL ID="livelogdata"></UL>
</DIV>
<DIV CLASS="debugmenu">
</DIV>
。$( '#livelog')停止(真); - 不工作