如何利用javascript保持状态?

chineseyounger 2004-11-21 06:02:37
一个框架页中包含a.html和b.html,点a.html就刷新b.html,如果b.html中有一个input框,在框中填上了数字。如何在刷新b.html中框中的数字不会被刷掉!有没有javascript语句来保存谢谢!
能否给出详细的写法!?
...全文
109 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
hanyun229 2004-11-22
  • 打赏
  • 举报
回复
up
HHH3000 2004-11-22
  • 打赏
  • 举报
回复
非常感谢ttyp(愿赌服输) ^_^
又学了一着!
ttyp 2004-11-22
  • 打赏
  • 举报
回复
userdata是IE的一个行为,保存数据用的

Security Alert For security reasons, a UserData store is available only in the same directory and with the same protocol used to persist the store.
Security Alert Using this behavior incorrectly can compromise the security of your application. Data in a UserData store is not encrypted and therefore not secure. Any application that has access to the drive where UserData is saved has access to the data. Therefore, it is recommended that you not persist sensitive data like credit card numbers. For more information, see Security Considerations: DHTML and Default Behaviors.
The userData behavior persists information across sessions by writing to a UserData store. This provides a data structure that is more dynamic and has a greater capacity than cookies. The capacity of the UserData store depends on the security zone of the domain. The following table shows the maximum amount of UserData storage that is available for an individual document and also the total available for an entire domain, based on the security zone.

Security Zone Document Limit (KB) Domain Limit (KB)
Local Machine 128 1024
Intranet 512 10240
Trusted Sites 128 1024
Internet 128 1024
Restricted 64 640


The userData behavior persists data across sessions, using one UserData store for each object. The UserData store is persisted in the cache using the save and load methods. Once the UserData store has been saved, it can be reloaded even if Microsoft® Internet Explorer has been closed and reopened.

Setting the userData behavior class on the html, head, title, or style object causes an error when the save or load method is called.

HHH3000 2004-11-22
  • 打赏
  • 举报
回复
借个地方问一下:
请问ttyp(愿赌服输) ,
userdata是什么东东???
chineseyounger 2004-11-21
  • 打赏
  • 举报
回复
估计大家没看明白我的意思!
我在b.htm中有个表格a.b.c我点a的时候,a在text框中,当我点a.htm中的提交按钮时就刷新b.htm,这时候a就会被刷没!如何保持住a不会被刷没谢谢!
ttyp 2004-11-21
  • 打赏
  • 举报
回复
你可能不是刷新吧,reload刷新一般不会刷掉的

不过你还是可以用userdata来保存数据,即使关闭了窗口也不会掉

<HTML>
<HEAD>
<STYLE>
.storeuserData {behavior:url(#default#userData);}
</STYLE>
<SCRIPT>
function fnSaveInput(){
var oPersist=oPersistForm.oPersistInput;
oPersist.setAttribute("sPersist",oPersist.value);
oPersist.save("oXMLBranch");
}
function fnLoadInput(){
var oPersist=oPersistForm.oPersistInput;
oPersist.load("oXMLBranch");
oPersist.value=oPersist.getAttribute("sPersist");
}
</SCRIPT>
</HEAD>
<BODY>
<FORM ID="oPersistForm">
<INPUT CLASS="storeuserData" TYPE="text" ID="oPersistInput">
<INPUT TYPE="button" VALUE="Save" onclick="fnSaveInput()">
<INPUT TYPE="button" VALUE="Load" onclick="fnLoadInput()">
</FORM>
</BODY>
</HTML>
APTX876 2004-11-21
  • 打赏
  • 举报
回复
我记得input.value是不会被刷掉的

//除了type=password

87,901

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧