Javascript
共 10 篇文章
区分Android 和IOS
<script type="text/javascript"> window.onload = function (){ var _val = navigator.platform ; var _appVerson = navigator.appVersion; //alert("appVesion :" + _appVerson) if(_val.indexOf("iPad") != -1 || _val.indexOf("iPhone") != -1 ){ //iphone }else if(_appVerson.match(/linux/i)){ //X11是UC浏览器的平台 //an…
2015-02-05 15:12 · Javascript
js 未上传预览
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <body> <input type=file name="doc" id="doc" onchange="javascript:setImagePreview();"> <p> <div id="localImag"><img id="preview" width=-1 he…
2013-06-07 22:12 · Javascript
JavaScript 实现图片待上传预览
<script type="text/javascript"> function preview5(){ document.getElementById("delImgButton").style.display = "none"; var x = document.getElementById("file5"); if(!x || !x.value) return; var patn = /\.jpg$|\.jpeg$|\.gif$|\.bmp$/i; if(patn.test(x.value)){ var imgType = checkImgType(x.value); var num …
2011-08-07 22:50 · Javascript
常用脚本整理
//Js触发按钮事件 var WsShell = new ActiveXObject("WScript.Shell"); WsShell.SendKeys("{F11}"); //窗口大小改变事件 window.onresize=function(){ if(document.documentElement.clientHeight < document.documentElement.offsetHeight-4){ //判断是否有滚动条 } }
2011-05-24 22:49 · Javascript
禁止网页上右键和另存为
<html> <head> </head> <body oncontextmenu="return false" onselectstart="return false"> <noscript> <iframe scr="*.htm"></iframe> </noscript> </body> </html>
2011-05-24 22:47 · Javascript
js清空TYPE=file
function cleanFile(id){ var _file = document.getElementById(id); if(_file.files) _file.value = ""; else { if (typeof _file != "object") return null; var _span = document.createElement("span"); _span.id = "__tt__"; _file.parentNode.insertBefore(_span,_file); var tf = document.createElement("form"); …
2010-04-27 16:33 · Javascript
添加到收藏夹JS
function addCookie() { if (document.all) { window.external.addFavorite('url','name'); } else if (window.sidebar) { window.sidebar.addPanel('name', 'url', ""); } }
2010-03-29 10:15 · Javascript
验证数字的正则表达式集
验证数字:^[0-9]*$ 验证n位的数字:^\d{n}$ 验证至少n位数字:^\d{n,}$ 验证m-n位的数字:^\d{m,n}$ 验证零和非零开头的数字:^(0|[1-9][0-9]*)$ 验证有两位小数的正实数:^[0-9]+(.[0-9]{2})?$ 验证有1-3位小数的正实数:^[0-9]+(.[0-9]{1,3})?$ 验证非零的正整数:^\+?[1-9][0-9]*$ 验证非零的负整数:^\-[1-9][0-9]*$ 验证非负整数(正整数 + 0) ^\d+$ 验证非正整数(负整数 + 0) ^((-\d+)|(0+))$ 验证长度为3的字符:^.{3}$ 验证由26个英文字…
2009-12-24 13:02 · Javascript
window.opener 的用法
window.opener 的用法 window.opener 返回的是创建当前窗口的那个窗口的引用,比如点击了a.htm上的一个链接而打开了b.htm,然后我们打算在b.htm上输入一个值然后赋予a.htm上的一个id为“name”的textbox中,就可以写为: window.opener.document.getElementById("name").value = "输入的数据"; 对于javascript中的window.opener没有很好的理解。 为什么框架中不能使用,弹出窗口的父窗口不能在框架里面的某个页面呢?那怎样通过弹出窗口操作框架中的父窗口呢? opener.paren…
2009-12-01 09:00 · Javascript
Javascript 容错
2009-08-20 20:14 · Javascript