Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/418.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中将值从一个页面传递到另一个页面_Javascript - Fatal编程技术网

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

如何在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="btn

您好,我有一个用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);
    }

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

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

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

要发送大量数据,您可以尝试以下方法:

  • 创建表单时,方法post和操作等于要重定向到的url(表单可以隐藏-这不是问题)
  • 在此表单中创建
    textarea
    /
    text
    字段(不必要)
  • 将您的数据放入此文本区域
  • 通过JS提交表格
  • 在新页面上接收数据

  • 注意,javascript将以这种形式转义数据。要取消它,请使用函数。

    它是否在同一个域上?可能重复@Jamie?我不同意,因为可能的解决方案不一定是查询string@aduch:不一定,但这是一种可能的解决方案。@CBroe同意注释
    的这一部分,因为您使用的是ASP,您可以这样做:
    他使用的东西不是必需的。您建议使用简单的查询字符串。它在web中工作,但不仅仅在asp中工作
    function Redirect() {
        window.open ("http://10.19.13.67/ReworkLabels/Default.aspx?myVariable=" + myVariable,"my window");
        return false;
    }