javascript - 如何在javascript中将值从一个页面传递到另一个页面

标签 javascript

嗨,我有一个用 javascript 创建的表,我需要知道的是如何使用 javascript 通过单击按钮将第 1 行或第 2 行中的值传递到 aspx 页面中: 这是我的 JavaScript 代码:

newContent += Hesto.Html.StartTR(item.CommonCable, 'lineInfoRow');
            newContent += Hesto.Html.CreateTD('<input type="button" value="Print" id="btnprint" onclick="Redirect()">',null);
            newContent += Hesto.Html.CreateTD(item.CommonCable, null, null);
            newContent += Hesto.Html.CreateTD(item.Wire, null, null);
            newContent += Hesto.Html.CreateTD(item.WireLength * 1000, null, 'centerAlign');
            newContent += Hesto.Html.CreateTD(item.TerminalA, null, (sideFlag == 1 ? 'highlightOneSide' : (sideFlag == 3 ? 'highlightTwoSides' : 'highlightNone')));
            newContent += Hesto.Html.CreateTD(item.SealA, null, (sideFlag == 1 ? 'highlightOneSide' : (sideFlag == 3 ? 'highlightTwoSides' : 'highlightNone')));
            newContent += Hesto.Html.CreateTD(item.TerminalB, null, (sideFlag == 2 ? 'highlightOneSide' : (sideFlag == 3 ? 'highlightTwoSides' : 'highlightNone')));
            newContent += Hesto.Html.CreateTD(item.SealB, null, (sideFlag == 2 ? 'highlightOneSide' : (sideFlag == 3 ? 'highlightTwoSides' : 'highlightNone')));
            newContent = Hesto.Html.EndTR(newContent);
        });

        $('#AlternativeReworkCablesList').html(newContent);
    }

这是我的重定向页面:

function Redirect() {
    window.open ("http://10.19.13.67/ReworkLabels/Default.aspx","my window");
    return false;
}

最佳答案

您有几个选择:您可以将数据保存在 cookie 中以便稍后重复使用,您可以将数据作为一系列 GET 变量传递到下一页,或者您可以加载使用 AJAX 访问下一页,以便您的变量保持可用。

由于您使用的是 ASP,因此您可以执行以下操作:

function Redirect() {
    window.open ("http://10.19.13.67/ReworkLabels/Default.aspx?myVariable=" + myVariable,"my window");
    return false;
}

关于javascript - 如何在javascript中将值从一个页面传递到另一个页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23561454/

相关文章:

javascript - (从默认导出导入)Redux 中的根 reducer 是否自动称为 'rootReducer' ?

javascript - 下拉内容更改的问题

javascript - 设置默认单选按钮 + 关联的 Div

javascript - 修改svg xlink :href through knockout attr binding

javascript - js文件路径正确但是加载不出来

javascript - JS : How to return 'undefined' instead of throwing error 'cannot read property x of undefined'

javascript - 将值从 php 回显到 javascript

javascript - HTML5 - 碰撞

javascript - 如何从异步调用返回响应?

javascript - 当我使用 <a> 标签跟随路线时,React-Router 正在刷新页面