任何人都可以帮助我理解如何存储另一种语言的cookie值,以及如何以该语言再次检索它.
在存储后检索时,我的外语cookie似乎变成了垃圾.
一些代码:
写cookie代码:
function writecook() {
document.cookie = "lboxcook=" + document.getElementsByTagName('input')[0].value;
//input[0] is the input box who's value is stored
}
Run Code Online (Sandbox Code Playgroud)
检索Cookie代码:
<script language="JavaScript">
function get_cookie ( cookie_name )
{
var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
if ( results )
return ( unescape ( results[2] ) );
else
return null;
}
</script>
Run Code Online (Sandbox Code Playgroud)
谢谢.