使用参数

时间:2016-10-06 09:15:41

标签: javascript jquery html5

我想使用参数例如array c []从a.html重定向到b.html,我使用location.href = "b.html";之类的东西但是当我在我的.js中写console.log(c[0].name);之类的东西时重定向到b.html之后什么也没得到! 在此先感谢您的帮助:))



$(".btn").click(function(){
    location.href = "b.html"; 
    //.. push of some elemts to the array elements
    // .. try to show elements in b.html with console.log() for example
});




1 个答案:

答案 0 :(得分:0)

如前所述,重定向后,您确实在新页面上。所以你以前所做的一切都是卸载的。 (并且在设置location.href后应该执行的脚本停止)

有几种方法可以将数据处理到下一页,但到目前为止最简单的方法是在URI中使用query-parameter。检查出来:
https://en.wikipedia.org/wiki/Query_string

你受到数据大小的限制,数据在某种程度上是可见的,但它可能很容易被黑客攻击 - 但似乎你现在还处于起步阶段。(?)