![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
JAVASCRIPT
一丢丢的幸福
这个作者很懒,什么都没留下…
展开
-
js验证是否是中文
JS验证是否为中文这个找了好久网上80%的好像都不能用 终于在csdnzhaoda转载 2014-09-18 10:17:58 · 552 阅读 · 0 评论 -
js判断上传文件类型
js判断多文件上传,单文件上传文件格式判断原创 2015-04-16 10:28:40 · 1609 阅读 · 0 评论 -
JS判断一个数组中是否有重复值的三种方法
方法一: var s = ary.join(",")+",";for(var i=0;iif(s.replace(ary[i]+",","").indexOf(ary[i]+",")>-1) {alert("数组中有重复元素:" + ary[i]);break;}}方法二: var ary = new Array("111","22","33转载 2014-12-02 16:01:21 · 1482 阅读 · 0 评论 -
客户端设置cookie保存用户名密码
//设置cookie值 function SetCookie(usern,psw){ var Then = new Date() Then.setTime(Then.getTime() + 1866240000000) document.cookie ="username=" + usern + "%%"+psw+";expires="+ Then.toGMTS原创 2015-01-27 16:43:19 · 511 阅读 · 0 评论 -
点击弹出一个窗口,再点击任意地方窗口关闭
$(function(){ $("#relateExplain").hide(); $("#dyExplain").hide(); $("#relateExplainBtn").click(function(){ if(window.event) event.cancelBubble = true; else event.stopPropagation(); $原创 2014-06-19 11:30:33 · 4241 阅读 · 0 评论 -
判断滚动条是否到达页面底部
当我们有这样的需求时(要求滚动条到达页面底部时,再加载后面的多少条数据)可以使用如下代码(这段代码同样适用于手机端web开发):window.onscroll=function(){ var a = document.documentElement.scrollTop==0? document.body.clientHeight : document.documentElement.clientH原创 2014-06-19 11:30:54 · 650 阅读 · 0 评论 -
Enter事件
document.onkeydown=keyListener; function keyListener(e){ e = e ? e : event;// 兼容FF if(e.keyCode == 13){ chkUserInfo(); }}原创 2014-06-19 11:30:39 · 540 阅读 · 0 评论 -
alert效果类似的js代码
最近项目要求显示提示信息时不能有来自网址“。。。。”的显示,之前都是用的alert做的提示,所以不同的浏览器显示的提示是不一样的,尤其是我们这个项目,在手机端 显示时总是带有网站的域名显示:比如修改之前的提示信息是(来自www.weixin.com的显示:请输入正确的QQ号),修改后的就自己看图吧,还是先上代码吧:①:css:*{ padding:0; margin:0;}#bg{backgrou原创 2014-06-19 11:30:37 · 2373 阅读 · 0 评论 -
返回顶部隐藏显示的控制代码
js $(function() { $(window).scroll(function() { if ($(this).scrollTop() > 1) { //当window的scrolltop距离大于1时,go to top按钮淡出,反之淡入 $("#gotoTop").fadeIn(); } else {原创 2014-07-28 16:04:45 · 1565 阅读 · 0 评论 -
js获取屏幕宽度和高度
JS获取屏幕高度var s = "";s += " 网页可见区域宽:"+ document.body.clientWidth;s += " 网页可见区域高:"+ document.body.clientHeight;s += " 网页可见区域宽:"+ document.body.offsetWidth +" (包括边线和滚动条的宽)";s += " 网页可见区域高:"+ document.body原创 2014-06-19 11:31:00 · 470 阅读 · 0 评论 -
js监听文本框输入字数,字数超出限定个数则提示信息变红
还可输入30个汉字 function countNum(e){ var value=$(e).val(); var cArr = value.match(/([\u0391-\uffe5])/ig); // 返回中文的字符 var num=Math.floor((90-value.length-2*(cArr == null ? 0原创 2014-06-19 11:31:12 · 6238 阅读 · 0 评论 -
菜单鼠标移入移出切换图片
经常看到网站上有那种菜单,当鼠标移上去时图片变成红色,移开后又变成原来的白色,这里给出实现的 代码 button1up = new Image(20, 29); button1up.src = "../institute/decoratorFont/images/1x_1.png"; button1down = new Image(20, 29); button1down.src = "原创 2014-06-19 11:31:26 · 869 阅读 · 0 评论 -
js获取鼠标位置
xmlns="http://www.w3.org/1999/xhtml">JavaScript获取鼠标坐标http-equiv="Content-Type" content="text/html; charset=gb2312" />type="text/css">.tip {width:200px;border:2px solid #ddd;padding:8px;background:#f1f原创 2014-06-19 11:31:34 · 433 阅读 · 0 评论 -
走马灯
//插件(function($){ $.fn.Xslider = function(options){var settings ={ affect: 'scrollx', //crollx|scrolly|fade|none speed: 1200, //动画速度 space: 6000, //时间间隔 auto: true, //自动滚动 trigger: 'm原创 2014-09-15 15:44:40 · 597 阅读 · 0 评论 -
iframe实现高度自适应,兼容FF、Opera、Safari
转自:iframe实现高度自适应,兼容FF、Opera、Safari转载 2014-09-19 17:54:01 · 954 阅读 · 0 评论 -
window.open()
if (document.all) {//IEfeature = "dialogWidth:1002px;dialogHeight:590px;status:no;help:no";window.showModalDialog("${basePath}/page/toservice.html", null, feature);}else {//非IEfeature = "w原创 2015-07-01 14:35:24 · 344 阅读 · 0 评论