87,984
社区成员
发帖
与我相关
我的任务
分享<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" language="javascript" src="jquery-1.9.0.js"></script>
<script type="text/javascript" language="javascript">
$(function(){
var str='';
var int=1;
while(int<=100){
str+=int+'<br />';
++int;
}
$("#div").html(str);
})
$(function(){
$("#div").scroll(function(e) {
$('title').html($(this).scrollTop());
document.cookie='cname='+$(this).scrollTop()+';expires='+setTimes();
status=document.cookie;
});
})
$(function(){
if(!document.cookie){
return;
}
var cookie=document.cookie;
var reg=/cname=([^;]+)(;|$)/;
$("#div").scrollTop(cookie.match(reg)[1]);
})
function setTimes(){
var date=new Date();
date.setTime(date.getTime()+1000*60);//设置cookie时间为1分钟
return date.toUTCString();
}
</script>
</head>
<body>
<div id="div" style="width:600px; height:400px; border:#000000 1px solid; overflow-y:scroll; margin:0 auto;"></div>
<a href="Untitled-2.html">asfdasdfasd</a>
</body>
</html>