/**
* id数组转换为json字符串
*/
function arrayTojson(arr) {
var jsonIds = "[";
for ( var i = 0; i < arr.length; i++) {
if (i == arr.length - 1) {
jsonIds += arr[i].eventid;
} else {
jsonIds += arr[i].eventid + ",";
}
}
return jsonIds += "]";
}
 /**
* 获取系统的url
* @returns fullUrl:系统访问路径,例如:http://localhost:8080/amudraya/amudraya
*/
function getURL(){
var fullUrl = window.location.href;
var a=fullUrl.lastIndexOf('/');
fullUrl=fullUrl.substring(0,a);
var b=fullUrl.lastIndexOf('/');
fullUrl=fullUrl.substring(0,b);
var c=fullUrl.lastIndexOf('/');
fullUrl=fullUrl.substring(0,c);
return fullUrl;
}

Js验证码

 /**========================验证码开始=============**/
var code ; //在全局 定义验证码
function createCode(){
code = "";
var codeLength = 4;//验证码的长度
var checkCode = document.getElementById("checkCode");
checkCode.value = "";
var selectChar = new Array(1,2,3,4,5,6,7,8,9,
'a','b','c','d','e','f','g','h','j','k','l','m','n','p','q',
'r','s','t','u','v','w','x','y','z','A','B','C','D','E','F',
'G','H','J','K','L','M','N','P','Q','R','S','T','U','V','W','X','Y','Z'); for(var i=0;i<codeLength;i++) {
var charIndex = Math.floor(Math.random()*60);
code +=selectChar[charIndex];
}
if(code.length != codeLength){
createCode();
}
checkCode.value = code;
}
function validate () {
var inputCode = document.getElementById("loginCodeId").value.toUpperCase();
var codeToUp=code.toUpperCase();
if(inputCode.length <=0) {
alert("请输入验证码!");
return false;
}
else if(inputCode != codeToUp ){
alert("验证码输入错误!");
createCode();
return false;
}
else {
return true;
}
}
/**======================验证码结束==================**/
/**
* 关闭忘记密码页面
*/
function closeWindow(){
$win.window('close');
}

JS通用方法总结(一)的更多相关文章

  1. JS通用方法扩展

    /* * 系统中JS的扩展函数 * * */ // 清除两边的空格 String.prototype.trim = function() { returnthis.replace(/(^\s*)|(\ ...

  2. js通用方法检測浏览器是否已安装指定插件(IE与非IE通用)

    /* * 检測是否已安装指定插件 * * pluginName 插件名称 */ function checkPlugins(pluginName) { var np = navigator.plugi ...

  3. js添加事件通用方法

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  4. 常用js字符串方法学习总结

    2016-06-15 js数组和字符串方法有很多,并且有一部分在使用的过程中有很多方法是很容易被混淆的,今天来总结一下js中数组和字符串的方法. ♦数组(Array)的方法 1.push() 和 po ...

  5. 使用 highchart 绘制柱状图的通用方法与接口

    本文给出使用 highchart 绘制柱状图的通用方法与接口, 只要指定相应的数据结构和配置, 就可以直接拿来使用. 一.  数据结构与基本接口   一般绘制图形, 会涉及到较复杂的数据结构, 比如使 ...

  6. 设计js通用库

    设计js通用库的四个步骤: 1.需求分析:分析库需要完成的所有功能. 2.编程接口:根据需求设计需要用到的接口及参数.返回值. 3.调用方法:支持链式调用,我们期望以动词方式描述接口. (ps:设计链 ...

  7. 使用JsPlumb绘制拓扑图的通用方法

    转自:http://www.it165.net/pro/html/201311/7616.html 使用JsPlumb绘制拓扑图的通用方法 一. 实现目标 绘制拓扑图, 实际上是个数据结构和算法的问题 ...

  8. 使用 JsPlumb 绘制拓扑图的通用方法

    摘要: 实现 JsPlumb 绘制拓扑图的通用方法. 只要服务端返回一个符合指定格式的数据结构,就可以绘制相应的拓扑图. 难度: 中级 示例工程见:  http://download.csdn.net ...

  9. jsonp跨域 封装通用方法

    jsonp跨域 封装通用方法 //用法如下 jsonp({ url:"https://www.xxxx.com", params:{wd:'b'}, callback:'show' ...

随机推荐

  1. JAVA 显示图片的简单源码 分类: Java Game 2014-08-14 10:10 77人阅读 评论(0) 收藏

    此代码的原理就是用JLabel来加载图片,再将JLabel放入JFrame中, package com.mywork; import javax.swing.ImageIcon; import jav ...

  2. HDU1014Uniform Generator

    Uniform Generator Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   ...

  3. 一个利用window.name实现的windowStorage

    //key:value|key:value var windowStorage = { _inited: false, _data: {}, init: function(str) { var tmp ...

  4. linux gcc loudong

    五事九思 (大连Linux主机维护) 大连linux维护qq群:287800525 首页 日志 相册 音乐 收藏 博友 关于我     日志       spcark_0.0.3_i386.src.t ...

  5. iOS验证码倒计时(GCD实现)

    + (void)verificationCode:(void(^)())blockYes blockNo:(void(^)(id time))blockNo { __block ; //倒计时时间 d ...

  6. HDU 2709 Sumsets(递推)

    Sumsets http://acm.hdu.edu.cn/showproblem.php?pid=2709 Problem Description Farmer John commanded his ...

  7. C# 比较方法

    public int Compare(Product first, Product second) { return PartialComparer.RefernceCompare(first, se ...

  8. facebook design question 总结

    http://blog.csdn.net/sigh1988/article/details/9790337 这里原帖地址: http://www.mitbbs.com/article_t/JobHun ...

  9. poj 3328(多起点多终点的最短路)

    题目链接:http://poj.org/problem?id=3328 思路:这道题花了我将近3个小时,结果发现是方向搞错了,orz,过了样例之后提交wa,然后换成优先队列就过了.其实题目意思很简单, ...

  10. spring_150802_resource

    接口Service: package com.spring.service; public interface DogPetService { public void queryAllDogPets( ...