Function inituserdata ()
{
If (testie () document.doc umentelement. addbehavior ("# default # userdata ");
}
Function testie ()
{
Return !! Document. All;
}
Function setuserdata (Key, value ){
VaR ex;
If (testie () {// IE
With(document.doc umentelement)
Try {
Load (key );
VaR otimenow = new date ();
Otimenow. setminutes (otimenow. getminutes () + 1440 );
Expires = otimenow. toutcstring ();
Setattribute ("value", value );
// Expires = new date ()-(-86400000). toutcstring ();
// Expires = new date ()-(-86400000). togmtstring ();
Save (key );
Return getattribute ("value ");
} Catch (Ex ){
Return;
}
} Else if (window. sessionstorage) {// FF 2.0 +
Try {
Sessionstorage. setitem (Key, value)
} Catch (Ex ){
Return;
}
} Else {
Return;
// Alert ("error occured in user data saving. Your browser do not support user data .");
}
}
Function getuserdata (key ){
VaR ex;
If (testie () {// IE
With(document.doc umentelement)
Try {
Load (key );
Return getattribute ("value ");
} Catch (Ex ){
Return;
}
} Else if (window. sessionstorage) {// FF 2.0 +
Try {
Return sessionstorage. getitem (key );
} Catch (Ex ){
Return;
}
} Else {
Return;
// Alert ("error occured in user data loading. Your browser do not support user data .")
}
}
Function deluserdata (key ){
VaR ex;
If (testie () {// IE
With(document.doc umentelement)
Try {
Load (key );
Removeattribute ("value ");
// Expires = new date (315532799000). toutcstring ();
// Expires = new date ()-86400000). togmtstring ();
Save (key );
} Catch (Ex ){
Return;
}
} Else if (window. sessionstorage) {// FF 2.0 +
Try {
Sessionstorage. removeitem (key );
} Catch (Ex ){
Return;
}
} Else {
Return;
// Alert ("error occured in user data deleting. Your browser do not support user data .")
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.