简体   繁体   English

在多个网页中使用的javascript变量

[英]A javascript variable used in multiple Web pages

Is there any way to define a variable that can be used in multiple Web pages? 有没有办法定义一个可以在多个网页中使用的变量? For example, a string variable stores a certain value in page A and that value can be accessed in page B. I know cookies can do it. 例如,字符串变量在页面A中存储某个值,并且可以在页面B中访问该值。我知道cookie可以执行此操作。 Is there any other way? 还有其他方法吗?

In descending order or support: Passing it in the URI, cookies, frames, HTML5 storage 按降序或支持:将其传递到URI,cookie,框架,HTML5存储中

Cookies are the sensible approach. Cookie是明智的做法。 It is what they were designed for. 这是他们的设计目标。

window.name can also hold about 2MB of data as a string. window.name也可以将大约2MB的数据保存为字符串。

See: http://www.thomasfrank.se/sessionvars.html 见: http//www.thomasfrank.se/sessionvars.html

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

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