jquery cookie和js文件中使用encodeURI()方法
来源:互联网 发布:终结者 知乎 编辑:程序博客网 时间:2024/06/09 23:58
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%@ page import="java.util.*"%><%@ page import="java.sql.*"%><%@ page import="java.io.*"%><%@ page import="com.jspsmart.upload.*" %><%@ include file="../../pub/s_token_learner.jsp"%><%/*1.js文件中使用encodeURI()方法。login_name = encodeURI(encodeURI(login_name)); 2.action中URLDecoder解码loginName = java.net.URLDecoder.decode(loginName,"UTF-8"); */ request.setCharacterEncoding("UTF-8"); String infoName=java.net.URLDecoder.decode(request.getParameter("infoName"));String type=request.getParameter("type");%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Cache-Control" content="no-cache"><meta http-equiv="Expires" content="0"><title>中国移动网上大学</title><link href="../../css/style.css" rel="stylesheet" type="text/css" /><link href="../../css/common.css" rel="stylesheet" type="text/css" /><link href="../../css/New_added.css" rel="stylesheet" type="text/css" /><script type="text/javascript" src="../../js/jquery-1.7.2.min.js"></script><script type="text/javascript" src="../../js/jquery.cookie.js"></script><script type="text/javascript" src="../../js/fudong.js"></script><script type="text/javascript" src="../../js/xialacaidan.js"></script><script type="text/javascript">$(function(){var date = new Date(); date.setTime(date.getTime() + (30 * 24 * 60 * 60 * 1000)); var his_url = document.URL;var canAdd = true; //初始可以插入cookie信息 标识位var hisUserId = $.cookie("<%=ut_userId_s%>"); var len = 0; if(hisUserId){ hisUserId = eval("("+hisUserId+")"); len = hisUserId.length; } $(hisUserId).each(function(){ //遍历里面的this if(this.infoName == "<%=infoName%>"){ canAdd = false; //已经存在,不能插入 return false; } });if(canAdd==true){ var json = "["; json += "{\"infoName\":\""+"<%=infoName%>"+"\",\"url\":\""+his_url+"\",\"type\":\""+"<%=type%>"+"\"},"; for(var i=0;i<len;i++){ //把以前的数据进行一次重构因为下面name要覆盖 json += "{\"infoName\":\""+hisUserId[i].infoName+"\",\"url\":\""+hisUserId[i].url+"\",\"type\":\""+hisUserId[i].type+"\"},"; } json += "{\"infoName\":\"\",\"url\":\"\",\"type\":\"\"}]"; $.cookie("<%=ut_userId_s%>",json,{expires:1}); } })</script></head><body><span>此处是进入资源页面,资源的标题名字是:<%=infoName%></span></body></html>
//获取当前时间function curentTime(){ var now = new Date(); var year = now.getFullYear(); //年 var month = now.getMonth() + 1; //月 var day = now.getDate(); //日 var hh = now.getHours(); //时 var mm = now.getMinutes(); //分 var ss = now.getSeconds(); //秒 var clock = year + "-"; if(month < 10) clock += "0"; clock += month + "-"; if(day < 10) clock += "0"; clock += day + " "; if(hh < 10) clock += "0"; clock += hh + ":"; if (mm < 10) clock += '0'; clock += mm + ":"; if (ss < 10) clock += '0'; clock += ss; return(clock); }
//打开此页面的课程学习信息写入cookiefunction initOnload(){ var nowTime=curentTime(); var examType=""; var canAdd = true; //初始可以插入cookie信息 标识位 var infoName=$(".sinfortitle").html(); var hisUserId = $.cookie("<%=ut_userId_s%>"); var len = 0; if(hisUserId){ hisUserId = eval("("+hisUserId+")"); len = hisUserId.length; } if(canAdd==true){ var json = "["; json += "{\"infoName\":\""+infoName+"\",\"enterId\":\""+"<%=classid%>"+"\",\"type\":\""+"CL"+"\",\"clickTime\":\""+nowTime+"\",\"examType\":\""+examType+"\"},"; if(len>=5){ for(var i=0;i<5;i++){ //把以前的数据进行一次重构因为下面name要覆盖 if(hisUserId[i].infoName!=infoName){ json += "{\"infoName\":\""+hisUserId[i].infoName+"\",\"enterId\":\""+hisUserId[i].enterId+"\",\"type\":\""+hisUserId[i].type+"\",\"clickTime\":\""+hisUserId[i].clickTime+"\",\"examType\":\""+hisUserId[i].examType+"\"},"; } } }else{ for(var i=0;i<len;i++){ //把以前的数据进行一次重构因为下面name要覆盖 if(hisUserId[i].infoName!=infoName){ json += "{\"infoName\":\""+hisUserId[i].infoName+"\",\"enterId\":\""+hisUserId[i].enterId+"\",\"type\":\""+hisUserId[i].type+"\",\"clickTime\":\""+hisUserId[i].clickTime+"\",\"examType\":\""+hisUserId[i].examType+"\"},"; } } }json += "{\"infoName\":\"\",\"enterId\":\"\",\"type\":\"\",\"clickTime\":\"\",\"examType\":\"\"}]"; $.cookie("<%=ut_userId_s%>",null); $.cookie("<%=ut_userId_s%>",json,{expires:30,path:'/'}); }}
http://www.helloweba.com/view-blog-147.html
0 0
- jquery cookie和js文件中使用encodeURI()方法
- javascript中encodeURI和decodeURI方法使用
- JS中为什么会存在escape、encodeURI和encodeURIComponent方法
- Js中escape(),encodeURI()和encodeURIComponent()使用和比较
- Js中escape(),encodeURI()和encodeURIComponent()使用和比较
- Js中escape(),encodeURI()和encodeURIComponent()使用和比较[转载]
- Js中escape(),encodeURI()和encodeURIComponent()使用和比较[转载]
- javascript中encodeURI和decodeURI方法使用介绍
- javascript中encodeURI和decodeURI方法使用介绍
- jquery.cookie.js使用
- jquery.cookie.js使用
- jquery.cookie.js使用
- jquery.cookie.js使用
- JQuery中$.cookie()方法的使用
- Js中escape(),encodeURI()和encodeURIComponent()比较
- Js中escape(),encodeURI()和encodeURIComponent()
- js中escape,encodeURI和encodeURIComponent区别
- javascript中encodeURI和decodeURI方法
- test9-5(用点类做成员的三角形类)
- centos 搭建svn服务器
- 信号量sem_t
- java中接口和抽象类的区别
- Django中的Python高级特性
- jquery cookie和js文件中使用encodeURI()方法
- Hive函数大全
- ArcGIS Engine 10.2 如何发布服务
- __attribute__机制介绍
- 编写简单的c运行库
- 面试知识总结(一)
- ietester下ie6 ie7停止工作问题的修复
- Yii CNumberFormatter的简单数字格式操作
- Cocos2d-x 的内存管理