繁体   English   中英

当页面被重定向时,如何在正在加载的页面的 innerhtml 中使用 javascript 变量?

[英]As a page is redirected how can I use a javascript variable in the innerhtml of the page being loaded?

foo() {
    var fooVar=7;
    location.assign("otherPage.php");
    otherPageobject.html=fooVar;
}

在一个页面上运行的代码不会影响另一个页面上的任何内容,因为一次只能加载/激活一个页面。 可以做的就是将您的价值发送到下一页。 例如:

location.assign("otherPage.php?fooVar=" + fooVar);

然后在另一个页面中,您可以从查询字符串中获取值并按照您认为合适的方式使用它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM