zoukankan
html css js c++ java
使用userdata保存客户端数据(从51js找到的)
从51js找到一些好东西,作个备忘
示例一:checkbox的使用
<
style
>
.userData
{behavior:url(#
default
#userdata);}
</
style
>
<
input type
=
checkbox id
=
chkbox1 class
=
userData
>
<
script
>
var
obj
=
document.all.chkbox1;
obj.attachEvent('onclick',saveChecked)
function
saveChecked()
{
obj.setAttribute(
"
bCheckedValue
"
,obj.checked);
obj.save(
"
oChkValue
"
);
}
window.attachEvent('onload',loadChecked)
function
loadChecked()
{
obj.load(
"
oChkValue
"
);
var
chk
=
(obj.getAttribute(
"
bCheckedValue
"
)
==
"
true
"
)
?
true
:
false
;
obj.checked
=
chk;
}
</
script
>
示例二:文本框标记的应用
<
HTML
>
<
HEAD
>
<
STYLE
>
.userData
{behavior:url(#
default
#userdata);}
</
STYLE
>
<
SCRIPT
>
function
fnSaveInput()
{
var
oPersist
=
oPersistForm.oPersistInput;
oPersist.setAttribute(
"
sPersist
"
,oPersist.value);
//
将oPersist.value存储为sPersist属性
oPersist.save(
"
oXMLBranch
"
);
//
存储在名为oXMLBranch的UserData存储区
}
function
fnLoadInput()
{
var
oPersist
=
oPersistForm.oPersistInput;
oPersist.load(
"
oXMLBranch
"
);
//
载入在名为oXMLBranch的UserData存储区
oPersist.value
=
oPersist.getAttribute(
"
sPersist
"
);
//
将sPersist属性赋值给oPersist.value
}
</
SCRIPT
>
</
HEAD
>
<
BODY
>
<
FORM ID
=
"
oPersistForm
"
>
<
INPUT CLASS
=
"
userData
"
TYPE
=
"
text
"
ID
=
"
oPersistInput
"
>
<
INPUT TYPE
=
"
button
"
VALUE
=
"
Load
"
onclick
=
"
fnLoadInput()
"
>
<
INPUT TYPE
=
"
button
"
VALUE
=
"
Save
"
onclick
=
"
fnSaveInput()
"
>
</
FORM
>
</
BODY
>
</
HTML
>
示例三:Select标记的应用
<
style
>
.userData
{behavior:url(#
default
#userdata);}
</
style
>
<
select id
=
"
select1
"
class
=
"
userData
"
>
<
option
>
option1
</
option
>
<
option
>
option2
</
option
>
<
option
>
option3
</
option
>
<
option
>
option4
</
option
>
</
select
>
<
script
>
var
obj
=
document.all.select1;
obj.attachEvent('onchange',saveSelectedIndex)
function
saveSelectedIndex()
{
obj.setAttribute(
"
sSelectValue
"
,obj.selectedIndex);
obj.save(
"
oSltIndex
"
);
}
window.attachEvent('onload',loadSelectedIndex)
function
loadSelectedIndex()
{
obj.load(
"
oSltIndex
"
);
obj.selectedIndex
=
obj.getAttribute(
"
sSelectValue
"
);
}
</
script
>
查看全文
相关阅读:
Emit介绍【转】
在.NET中使用反射实现简易插件机制【转】
RabbitMQ笔记-Qos与消息应答
Http级别缓存助手类(ASP.Net Core)
实现一个迷你IOC容器
使用CMake在Windows环境下的VS2019中配置openCV
如何在Visual Studio 2019中启动并配置一个使用pyTorch的C++项目(Windows系统,CMAKE项目)
windows环境下使用python中tensorflow的tensorboard功能无法创建指定路径的问题
使用python的selenium库自动填写网页(疫情每日一报)
十进制转换二进制toBinaryString源码分析
原文地址:https://www.cnblogs.com/yg_zhang/p/570428.html
最新文章
struct的使用场景
Mysql大数据量分页查询优化
TaskScheduler介绍【转】
.NET Core笔记-HostBuilder、Host
Quartz.net笔记
RabbitMQ笔记-发送消息属性Properties
RabbitMQ笔记-basicConsume、basicCancel、basicPublish等方法详解
Xunit笔记-Asserts
Xunit笔记-属性标签
防止async / await 阻塞死锁
热门文章
SynchronizationContext(线程间通讯)
RabbitMQ笔记-消费者优先级(x-priority)【转】
EasyNetQ笔记-替换EasyNetQ组件
EasyNetQ笔记-替换IOC容器
EasyNetQ笔记-预留
EasyNetQ笔记-预留
EasyNetQ笔记-Request/Response模式(请求响应)
EasyNetQ笔记-Publish/Subscribe模式(发布订阅)
EasyNetQ笔记-消息版本控制
EasyNetQ笔记-1介绍
Copyright © 2011-2022 走看看