为你而来

仿新浪博客滚动条后ajax加载评论

<html>
<head>
<title></title>
<style type='text/css'>
#one{
	border:solid 1px green;
	/*width:300px;
	height:200px;*/
}
</style>
<script language='javascript'>
	function fun2()
	{
		var object=document.getElementById('one');
		if(document.body.scrollTop+document.body.clientHeight>object.offsetHeight+30+(document.body.clientHeight/2)){
			alert('hello world');
			window.onscroll=null;
		}
	}
	
	window.onload=fun3;
	function fun3()
	{
		var object=document.getElementById('one')
		
		if(object.offsetHeight+30>document.body.clientHeight){
			window.onscroll=fun2;
		}
	}
</script>
</head>
<body>
<div id='one'>
<script language='javascript'>
	for(var i=0;i<100;i++)
	{
		document.write('3333<br/>');
	}
</script>
</div>
<script language='javascript'>
	for(var i=0;i<100;i++)
	{
		document.write('3333<br/>');
	}
</script>
</body>
</html>

 

posted on 2012-02-15 20:27  为你而来  阅读(1056)  评论(0编辑  收藏  举报

导航