原生的js跳转 把带过来的参数取出来的方法

本文介绍了一个使用JavaScript处理JSON数据并将其展示为HTML表格的方法。此外,还详细说明了如何在不同页面之间通过URL传递参数,并在目标页面上解析这些参数。

js第一个页面的管理

    for (var i = 0; i < jsonResult.data.list.length; i++) {

        var resource = jsonResult.data.list[i];
        var id = resource.id;
        var newCreateDate = new Date(resource.createDate);
        Y = newCreateDate.getFullYear() + '-';
        M = (newCreateDate.getMonth()+1 < 10 ? '0'+(newCreateDate.getMonth()+1)                       :newCreateDate.getMonth()+1) + '-';
        D = newCreateDate.getDate() + ' ';
        h = newCreateDate.getHours() + ':';
        m = newCreateDate.getMinutes() + ':';
        s = newCreateDate.getSeconds();
        var lastTime = Y+M+D+h+m+s;
        innerHTML +=
            "<tr>" +
            //在跳转路径上把参数带上
            "<td><a href='/admin/shareComplainDetail.jsp?id=" + id + "' >" + resource.id + "</a>            </td>" +
            "<td>" + resource.customerId + "</td>" +
            "<td>" + resource.customerName + "</td>" +
            "<td>" + resource.complaintReasonDes + "</td>" +
            "<td>" + resource.merchantId + "</td>" +
            "<td>" + resource.merchantName + "</td>"+
            "<td>" + resource.complaintStatus + "</td>"+
            "<td>" + lastTime + "</td>"
    }
第二个页面的详情
    //把url传过来的参数取出方法的id
    function GetRequest() {
        var url = location.search; //获取url中"?"符后的字串
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
                strs = str.split("&");
            for (var i = 0; i < strs.length; i++) {
                theRequest[strs[i].split("=")[0]] = decodeURIComponent(strs[i].split("=")[1]);
            }
        }
    return theRequest;
    }
    //调用这个方法取出id
    var shareComplaintDetailId=GetRequest();

    var detailId = shareComplaintDetailId.id;
    console.log(detailId);

转载于:https://my.oschina.net/pingheyongfeng/blog/994203

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值