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

同一个页面跳装 除了用锚点链接 js应该怎么写呢

<!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>
<style>
 .div{
 width:100px;
     height:100px;
     background:#099;
 float:left;
 }
.div1{
     width:100px;
     height:100px;
     background:#00BCF3;
 float:left;
 margin-top:1000px;
 display:inline;
  }
</style>
</head>
 
<body style="height:2000px;">
<a class="div" href="#div1"></a>
<div id="div1" class="div1"></div>
</body>
</html>

------解决方案--------------------

<script>
function jump(){
location.hash="div1";
}
</script>
<body style="height:2000px;">
<div class="div" id="cc" onclick="jump()"></div>
<div id="div1" class="div1"></div>
</body>