Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/394.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jquery代码可以转到上一个html页面吗?_Javascript_Jquery_Html - Fatal编程技术网

Javascript jquery代码可以转到上一个html页面吗?

Javascript jquery代码可以转到上一个html页面吗?,javascript,jquery,html,Javascript,Jquery,Html,首先,我创建如下数组 var files = ['index2.html', 'index.html','index3.html','index4.html']; 然后单击“上一步”按钮,我想一个接一个地返回html页面。但问题是,我有一个pagecounter,它链接到html页面(在数组中描述),我在div中加载了该页面。单击“上一步”按钮,我还想更新页码。作为参考,我正在上载图像。 函数backbtn(){ $(“#txtPageNo”).val()=i; //警报(y+“”); 警报(

首先,我创建如下数组

var files = ['index2.html', 'index.html','index3.html','index4.html'];
然后单击“上一步”按钮,我想一个接一个地返回html页面。但问题是,我有一个pagecounter,它链接到html页面(在数组中描述),我在div中加载了该页面。单击“上一步”按钮,我还想更新页码。作为参考,我正在上载图像。 函数backbtn(){

$(“#txtPageNo”).val()=i;
//警报(y+“”);
警报(“备份文件”);
var文件=['index2.html'、'index.html'、'index3.html'、'index4.html'];
警报('数组')
当(i>=1&&i尝试:

或:


您可以使用
window.history.back()

或者,如果你想让它完全适合你的情况,尽管history.back更好

var current=window.history.pathname.replace("index", "").replace(".html", "");
window.location = "index" + --current + ".html";
如上所述,使用window.history是一种更好的方法


希望有帮助

以下是我在“下一步”和“后退”按钮中使用的代码

带有更新页面计数器的“下一步”按钮

function nextbtn() {

        alert(txtPageNo.value+'');  
        //alert(i+'')
        alert('load files');

        var files = ['index2.html', 'index1.html','index3.html','index4.html'];
        while(txtPageNo.value<numItems )
            {
//              alert(i+'')
                alert(txtPageNo.value+'')
                var file = files[txtPageNo.value];

                $('#tabpage_1').load(file + '');
                document.getElementById('txtPageNo').value = txtPageNo.value++  ; 
                txtPageNo.value++;
                break;

            }


        }
函数nextbtn(){
警报(txtPageNo.value+“”);
//警报(i+“”)
警报(“加载文件”);
var文件=['index2.html'、'index1.html'、'index3.html'、'index4.html'];

while(txtPageNo.value=1&&a1可能需要
var i=$(“#txtPageNo”).val();
?是的,我使用此var a1=$(“#txtPageNo”).val();警报(a1);这很有效,伙计们,我无法在stackover flow中添加更多问题。请帮助我完成这项工作,正如我提到的,我还需要维护页面没有历史记录在我的情况下不起作用您还需要“维护页面”所以你不想加载一个新页面吗?我在Div标签中单击next/back按钮,一个接一个地加载html页面。在顶部,我显示的页码也像5中的1,2,5中的1,它与next函数一起工作,但我的逻辑与next按钮不起作用。在这种情况下,window.history对我没有帮助。window.history是一种基本的方法我知道,但在这里,我的scinario是不同的
window.history.back();
var current=window.history.pathname.replace("index", "").replace(".html", "");
window.location = "index" + --current + ".html";
function nextbtn() {

        alert(txtPageNo.value+'');  
        //alert(i+'')
        alert('load files');

        var files = ['index2.html', 'index1.html','index3.html','index4.html'];
        while(txtPageNo.value<numItems )
            {
//              alert(i+'')
                alert(txtPageNo.value+'')
                var file = files[txtPageNo.value];

                $('#tabpage_1').load(file + '');
                document.getElementById('txtPageNo').value = txtPageNo.value++  ; 
                txtPageNo.value++;
                break;

            }


        }
function backbtn() {

        var a1 = $("#txtPageNo").val();
        alert(a1);
        alert('back files');
        var files = ['index2.html', 'index1.html','index3.html','index4.html'];
        alert('array')

        while(a1>=1 && a1<=numItems)
        {


        document.getElementById('txtPageNo').value = a1-1; 
        a1 = a1 -2;
        alert(a1+'')
        var file = files[a1];

        $('#tabpage_1').load(file + '');
        break;

        }
        }