HTML怎么分页,index.html#home为第一个页面,以此类推?

html-css08

HTML怎么分页,index.html#home为第一个页面,以此类推?,第1张

类似#home这种链接是在一个页面内的跳转,跳转到的位置我们称之为“锚点”。下面的代码存到index.html即可查看效果<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Title</title></head><body><div style="position: fixedtop: 0left: 0background-color: #fff"><a href="#home">首页</a><a href="#page2">page2</a><a href="#page3">page3</a></div><div style="height: 800pxborder: 1px solid #dddpadding-top: 35px"><a id="home"></a><br><br>这里是首页部分</div><div style="height: 800pxborder: 1px solid #dddpadding-top: 35px"><a id="page2"></a><br><br>这里是page2部分</div><div style="height: 1000pxborder: 1px solid #dddpadding-top: 35px"><a id="page3"></a><br><br>这里是page3部分</div></body></html>

和一般的分页原理是一样的:

只不过文章的分页是通过substr()函数截取该页应当显示的文字内容

$content=substr($c1,strlen($c),strlen($c1)-strlen($c))

$c代表从文字开头到上一页文字末尾的内容

$c1代表从文字开头到当前页文字末尾的内容

当前页文字内容$content为$c1的内容减去$c的内容

这样做有一些缺陷,你做的时候会体会到的……

最常见的分页的代码是 :ASP PHP JSP

如果你的静态页面要分页 有一个 方法---JS

HTML上的分页JS代码

<form onsubmit="window.location=this.aaa.options[this.aaa.selectedIndex].valuereturn false">

<select name="select" onchange="javascript:window.location.href=this.options[this.selectedIndex].value">

<SCRIPT type=text/javascript>

for(var pN=1pN<184pN++)

document.write("<option value='Page_"+pN+".html'>第"+pN+"页</option>")

</SCRIPT>

</select></td></form>

加一个page=8的参数?

然后在for那里再用条件判断??

<form onsubmit="window.location=this.ep8.options[this.ep8.selectedIndex].valuereturn false">

<select name="select" onchange="javascript:window.location.href=this.options[this.selectedIndex].value">

<script type="text/javascript">

p=8

for(var i=1i<9i++)

if (i==p){

document.write("<option value='Page_"+p+".html' selected>第"+p+"页</option>")

}

else {

document.write("<option value='Page_"+i+".html'>第"+i+"页</option>")

}

</script>

</select></form>