我试图从一个页面传递一个变量,加载另一个页面并输入该信息。
像这样的东西:
当127.0.0.1/test.html&ID=1234时
location.href = "127.0.0.1/newpage.html"
if (location.href == newpage.html){
var e = document.GetElementById("Loginbx");
e.Value = ID
}
我无权修改 127.0.0.1/test.html 或 newpage.html,但想从另一个将变量传递给它们。这可能吗?
您可以传递查询字符串上的值,然后读取这些值:
location.href = "http://127.0.0.1/newpage.html?foo=1&bar=2";
然后使用 location.search 获取查询字符串并使用 Javascript 对其进行解析。只需确保查询字符串术语不会与可能存在的其他任何术语发生冲突。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)