Pass a variable to new page

隐身守侯 提交于 2019-12-04 05:35:40

问题


I am trying to pass a variable from one page, load another and enter that information. something Like this:

When 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
}

I don't have access to modify 127.0.0.1/test.html nor newpage.html but would like to pass variables to them from another. Is this possible?


回答1:


You could pass the values on the query string and then read those:

location.href = "http://127.0.0.1/newpage.html?foo=1&bar=2";

Then use location.search to get the query string and parse it with Javascript. Just make sure none of the query string terms collide with any others that may exist.



来源:https://stackoverflow.com/questions/3016449/pass-a-variable-to-new-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!