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

怎样在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页面没有自动刷新,无影响。

<SCRIPT language=javascript>

function GoPage(Myself)

{

var Lmyself=Myself.replace(".html","")

if (document.formpage.SkipPage.value == 1)

{window.location.href=Myself} //绝对路径可自己设置

else{

window.location.href=Lmyself+"_"+document.formpage.SkipPage.value+".html"

}

}

</SCRIPT>

<form name="formpage">

第<input name='SkipPage' onKeyDown='if(event.keyCode==13)event.returnValue=false' onchange="if(/

\D/.test(this.value)){alert('请输入需要跳转到的页数并且必须为整数!')this.value='1'}"

style='width: 20pxtext-align:center' type='text' value='1'>页

<input name='submitSkip' type='button' onClick='GoPage(window.location.href)' value='转到'></form>

给你改了一下,如果你的文件名为index.html,第2页就用index_2.html,第3页就用index_3.html即可 这样就可以了


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/7650286.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-08
下一篇2023-04-08

发表评论

登录后才能评论

评论列表(0条)

    保存