<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input type="button" value="取cookie" onclick="fun()">
</body>
<script type="text/javascript">
document.cookie ="username=asd";
document.cookie = "passwd=7344608";
document.cookie = "phone=151515151";
function fun() {
var data = document.cookie;
var result = [];
result = data.split(";");
var userIdData = result[0].split("=")[1];
var pwdData = result[1].split("=")[1];
var phoneData = result[2].split("=")[1];
document.write("用户名为:"+userIdData+"<br>");
document.write("密码为:"+pwdData+"<br>");
document.write("电话号码为:"+phoneData);
}
</script>
</html>
cookle
最新推荐文章于 2024-01-29 16:08:40 发布