[英]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.