帮忙修改下js代码
代码1:<scriptlanguage="javascript">thisurl=document.URL;urllen=thisurl.length;thispage=...
代码1:
<script language="javascript">
thisurl = document.URL;
urllen = thisurl.length;
thispage = thisurl.charCodeAt(urllen - 5);
document.write("<a href='");
document.write(thisurl.substring(0, urllen-5));
document.write(String.fromCharCode(thispage - 1));
document.write(".htm'>上一页</a> <a href='");
thispage[0] = thispage[0] + 2;
document.write(thisurl.substring(0, urllen-5));
document.write(String.fromCharCode(thispage + 1));
document.write(".htm'>下一页</a>");
</script>
代码2:
<script type="text/javascript">
document.onkeydown = chang_page;
function chang_page() {
if (event.keyCode == 37) location = 'http://www.baidu.com'
if (event.keyCode == 39) location = 'http://wap.baidu.com'
}
</script>
代码说明:
代码1:自动设置上一页、下一页链接,当访问页面为b时,上一页则为a,下一页则为b;当访问页面为02时,上一页则为01,下一页则为02……
代码2:在访问页面中按方向键“左”或“右”,即可转到其它网站。
修改要求:将两个代码合并在一起,即按方向键“左”或“右”时运行代码1。代码1只能在.htm中运行,其它会出错。 展开
<script language="javascript">
thisurl = document.URL;
urllen = thisurl.length;
thispage = thisurl.charCodeAt(urllen - 5);
document.write("<a href='");
document.write(thisurl.substring(0, urllen-5));
document.write(String.fromCharCode(thispage - 1));
document.write(".htm'>上一页</a> <a href='");
thispage[0] = thispage[0] + 2;
document.write(thisurl.substring(0, urllen-5));
document.write(String.fromCharCode(thispage + 1));
document.write(".htm'>下一页</a>");
</script>
代码2:
<script type="text/javascript">
document.onkeydown = chang_page;
function chang_page() {
if (event.keyCode == 37) location = 'http://www.baidu.com'
if (event.keyCode == 39) location = 'http://wap.baidu.com'
}
</script>
代码说明:
代码1:自动设置上一页、下一页链接,当访问页面为b时,上一页则为a,下一页则为b;当访问页面为02时,上一页则为01,下一页则为02……
代码2:在访问页面中按方向键“左”或“右”,即可转到其它网站。
修改要求:将两个代码合并在一起,即按方向键“左”或“右”时运行代码1。代码1只能在.htm中运行,其它会出错。 展开
3个回答
展开全部
function chang_page() {
thisurl = document.URL;
urllen = thisurl.length;
thispage = thisurl.charCodeAt(urllen - 5);
prevpage = thisurl.substring(0, urllen-5) + String.fromCharCode(thispage - 1) + ".htm";
thispage[0] = thispage[0] + 2;
nextpage = thisurl.substring(0, urllen-5) + String.fromCharCode(thispage + 1) + ".htm";
if (event.keyCode == 37) location = prevpage;
if (event.keyCode == 39) location = nextpage;
}
document.onkeydown = chang_page;
这样?
thisurl = document.URL;
urllen = thisurl.length;
thispage = thisurl.charCodeAt(urllen - 5);
prevpage = thisurl.substring(0, urllen-5) + String.fromCharCode(thispage - 1) + ".htm";
thispage[0] = thispage[0] + 2;
nextpage = thisurl.substring(0, urllen-5) + String.fromCharCode(thispage + 1) + ".htm";
if (event.keyCode == 37) location = prevpage;
if (event.keyCode == 39) location = nextpage;
}
document.onkeydown = chang_page;
这样?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询