Js_cookie保存登录名
生活随笔
收集整理的這篇文章主要介紹了
Js_cookie保存登录名
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head><title></title><script type="text/javascript">//獲取cookie
function getCookie(c_name) {if (document.cookie.length > 0) {c_start = document.cookie.indexOf(c_name + "=")if (c_start != -1) {c_start = c_start + c_name.length + 1c_end = document.cookie.indexOf(";", c_start)if (c_end == -1) c_end = document.cookie.lengthreturn unescape(document.cookie.substring(c_start, c_end))}}return ""}function setCookie(c_name, value, expiredays) {var exdate = new Date()exdate.setDate(exdate.getDate() + expiredays)document.cookie = c_name + "=" + escape(value) +
((expiredays == null) ? "" : "; expires=" + exdate.toGMTString())}//執行加載
function checkCookie() {username = getCookie('username'); //獲取cookieif (username != null && username != ""){ alert('Welcome again ' + username + '!') }else {username = prompt('Please enter your name:', "")if (username != null && username != "") {setCookie('username', username, 365)}}}</script>
</head>
<body οnlοad="checkCookie()">
</body>
</html>
?
轉載于:https://www.cnblogs.com/ingstyle/p/4207795.html
總結
以上是生活随笔為你收集整理的Js_cookie保存登录名的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [翻译] VLDContextSheet
- 下一篇: Oracle中rownum用法警示