怎样在HTML用代码实现内容换页

html-css06

怎样在HTML用代码实现内容换页,第1张

最常见的分页的代码是 :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>

将一个html页面中嵌入另一个html页面步骤如下:

1、首先,要嵌入html并不一定要写js代码,如图使用iframe标签,设置其src属性即可。注意其scrolling="auto"以添加滚动条。另外,其width和height要单独设置。

2、其链接到的html页面内容如图所示。给其添加如图meta标签,增加自动刷新功能。

3、在Python编写的httpserver中(Tornado),这两个url的请求都要处理。以本程序为例,用户浏览器载入main以后,main页面中的iframe标签会自动载入todolist。

4、如图是通过浏览器访问main页面,可以看到下面的框框中显示的就是todolist页面的内容。

5、另外,其右侧自带滚动条,而且这个潜入的页面设置了自动刷新,会时刻保持更新。

6、如果关闭了httpserver,会看到如簇所示情况,嵌入的页面刷新失败。但是main页面没有自动刷新,无影响。