常用html、demo代码
发布时间:2015-10-15, 14:45:06 分类:HTML | 编辑 off 网址 | 辅助
图集1/30
正文 9756字数 27,231,185阅读
暗网网址导航hidden wiki
http://zqktlwi4fecvo6ri.onion
Run code
Cut to clipboard
HTML特殊字符编码对照表
console.log(allnum);
javascript:;
vertical-align:middle;
strconv=yes+js
echo str_ireplace("WORLD","Shanghai","Hello world!");//不区分大小写
<a href="javascript:scroll(0,0)">返回顶部</a>
jquery多个节点绑定同一个事件
$('#begin,#end') 用逗号隔开
target="_blank"
index.php?g=Admin&m=Login
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
location.href = url;
autocomplete="off"
<form name="input" action="html_form_action.asp" method="get">
Username:
<input type="text" name="user" />
<input type="submit" value="提交" />
<input type="button" value="提交">
</form>
$.ajax({
type: "POST",
url:'/index.php?g=User&m=Post&a=Message&ajax=ajax',
data:$('#myform').serialize(),
error: function(request) {
alert("提交失败");
},
success: function(data) {
if(data>0){
alert('留言提交成功!');
location.reload();
}else alert("提交失败");
}
});
function ajaxpost(tel,pass){
$.ajax( {
url:"/index.php/Home/Register/is_login.html",
type: "post",
data:"tel="+tel+"&pass="+pass,
//dataType: "json",
//cache: false,
//async: false,
beforeSend: function(){
// Handle the beforeSend event
},
success: function(data){
}
});
}
<a href="javascript:scroll(0,0)">顶部</a> <a href="#copy">底部</a>
<meta charset="UTF-8" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
Run code
Cut to clipboard
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="icon" href="/favicon.ico">
<meta name="keywords" content="常用代码">
<meta name="description" content="isWTF's blog!!">
</head>
<body>
</body>
</html>
Run code
Cut to clipboard
$.ajax( {
url: '/index.php?s=/addon/WeiSite/WeiSite/ForgetPassword/tel/'+shoujihao+'/codeddd/'+codeddd+'.html', //这里是静态页的地址
type: "GET", //静态页用get方法,否则服务器会抛出405错误
//dataType: "json",
//cache: false,
//async: false,
beforeSend: function(){
// Handle the beforeSend event
},
success: function(data){
//var result = $(data).find("另一个html页面的指定的一部分").html();
}
});
Run code
Cut to clipboard
<link rel="apple-touch-icon" size="72x72" href="/icon-ipad.png" />
<link rel="apple-touch-icon" size="114x114" href="/icon-iphone4.png" />
<link rel="icon" href="/favicon.ico">
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<meta name="keywords" content="常用代码">
<meta name="description" content="isWTF's blog!!">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="format-detection" content="telephone=no" />
Run code
Cut to clipboard
I('post.id',0,'intval'); // 用intval过滤$_POST['id']
I('get.title','','strip_tags'); // 用strip_tags过滤$_GET['title']
Run code
Cut to clipboard
<meta name="title" content="标题">
<meta name="author" content="作者">
<meta name="description" content="描述">
<meta name="keywords" content="关键字">
<meta name="copyright" content="lizhenqiu.com">
移动端UC /QQ 浏览器的部分私有Meta 属性
下面就说下移动端UC /QQ 浏览器的部分私有Meta 属性,都来自其开发者文档(UC开发者中心,左下一doc文档,QQ浏览器)。
UC 浏览器的部分私有Meta 属性
设置屏幕方向为横屏还是竖屏
<meta name="screen-orientation" content="portrait|landscape">
设置是否全屏,yes表示强制浏览器全屏
<meta name="full-screen" content="yes">
缩放不出滚动条
<meta name="viewport" content="uc-fitscreen=no|yes"/>
设置no后用户缩放与标准浏览器缩放一直,设置为yes后,用户缩放金放到图片和文字,不出现横向滚动条。
排版
<meta name="layoutmode" content="fitscreen|standard" />
fitscreen模式简化页面处理,适合页面阅读节省流量,standard模式和标准浏览器一致;一旦设置layoutmode meta后,用户使用浏览器提供的的排版模式选项将会无效。
夜间模式
<meta name="nightmode" content="enable|disable"/>
nightmode的值设置为disable后,即使用户使用浏览器的夜间模式,页面的表现也仍然是非夜间模式。
强制图片显示
<meta name="imagemode" content="force"/>
UC浏览器为了节省流量,为用户提供了无图模式,但是如果页面的图片是必不可少的,如验证码的,需要强制浏览器显示图片,可以设置imagemode, 不影响子页面。通过META设置图片加载方式会作用于整个页面,如果希望对单个图片进行设置,那么可以使用这个
<img src="..." show="force">
应用模式
<meta name="browsermode" content="application"/>
使用了application这种应用模式后,页面讲默认全屏,禁止长按菜单,禁止收拾,标准排版,以及强制图片显示。
QQ 浏览器x5内核定制标签说明
设置屏幕方向
<meta name="x5-orientation" content="portrait|landscape" />
设置全屏
<meta name="x5-fullscreen" content="true" />
设置屏幕模式
<meta name="x5-page-mode" content="app" />
对于控制全屏的meta 标签,UC 跟QQ 处理的方式稍有不同:区别在于处理系统状态栏,UC 是直接覆盖系统状态栏,而QQ 仍然保留之。
Run code
Cut to clipboard
$("p").css("color","red");
//同时设置字体大小和背景色
$("p").css({"fontSize":"30px" ,"backgroundColor":"#ccc"});
$("button").click(function(){
$("div").animate({
left:'250px',
height:'+=150px',
width:'+=150px'
});
});
Run code
Cut to clipboard
header('Content-Type:text/html;charset=utf-8'); //避免输出乱码
<img title="点击刷新" src="cache/yzm.php" align="absbottom" onclick="this.src='cache/yzm.php?'+Math.random();" />
Run code
Cut to clipboard
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.9.0/jquery.min.js"></script>
<link rel="stylesheet" href="http://lizhenqiu.com/templates/default/style.css" type="text/css" media="screen">
<script type="text/javascript">jQuery(".slideTxtBox").slide(); </script>
Run code
Cut to clipboard
Yourphp手册
简单文本编辑器
data:text/html, <title>Text Editor</title><body contenteditable style="font-size:2rem;font-family:georgia;line-height:1.4;max-width:60rem;margin:0 auto;padding:4rem;"> lizhenqiu.com
Run code
Cut to clipboard
Chrome提供了一个简单的方法。首先,按“F12”打开控制台,然后输入:
document.designMode = "on"
Run code
Cut to clipboard
添加到收藏夹URL填写下面的即可在当前页面点击收藏夹编辑页面
javascript:(function(){document.designMode = "on" })();
Run code
Cut to clipboard
接下来,你就可以编辑屏幕上的文本内容了。
编辑器
data:text/html, <html contenteditable>
Run code
Cut to clipboard
如果你想找回不小心关闭的Tab页面,只需要同时按下“Control"(Mac用户请按“Command”)、“Shift"和“T”。
js随机数
function getRandom(n){
return Math.floor(Math.random()*n+1)
}
Run code
Cut to clipboard
top.location.href 和 localtion.href 有什么不同
top.location.href=”url”
Run code
Cut to clipboard
在顶层页面打开url(跳出框架)
self.location.href=”url”
Run code
Cut to clipboard
仅在本页面打开url地址
parent.location.href=”url”
Run code
Cut to clipboard
在父窗口打开Url地址
this.location.href=”url”
Run code
Cut to clipboard
用法和self的用法一致
if (top.location == self.location) 判断当前location 是否为顶层来 禁止frame引用 如果页面当中有自定义的frame的话,也可以将parent self top换为自定义frame的名称 效果就是在自定义frame窗口打开url地址
实际中可能这样使用
if(top !== self){ top.location.href = location.href; }
Run code
Cut to clipboard
以下是从网上找到的一个例子,不是很直观, 我加了上面那三行代码, 可以先去掉, 再加上, 看一下效果,就很清楚了 以下是top.htm 代码
<script language=javascript> function rs(){
if(top !== self){ top.location.href = location.href; } parent.left.location.href="top.htm" parent.bot.location.href="top.htm" } < /script> < input type=button name=name value="ksdj" onclick=rs();>
Run code
Cut to clipboard
以下是一个随意文件名的htm文件:
<FRAMESET COLS="150,*"> < FRAME SRC="left.htm" name=left> < FRAMESET ROWS="150,*"> < FRAME SRC="top.htm" name=top> < FRAME SRC="bot.htm" name=bot> < /FRAMESET> < /FRAMESET>
Run code
Cut to clipboard
top表示主窗口,location表示当前窗口,如果你的文件只有一个框架,没有iframe和frmaeset,那么是完全一致的,没有区别。
top.location是在顶层frame中打开新页
window.location是在当前frame中打开新页
parent.location 在当前窗口的父窗口打开Url地址
<select id="isAudit" name="isAudit">
<option value="2">全部</option>
<option value="1" selected = "selected">通过</option>
<option value="0">未通过</option>
</select>
Run code
Cut to clipboard
修改ID增加ID属性,修改class同理
$('.div').attr('id','newid');
如果是给标签添加class样式可以这样
$('#div').addClass('css类名');
strtotime("-1 week"), strtotime("-n days");可以很方便的获取当前日期的前n天、周、月的时间戳
Run code
Cut to clipboard
舒适网页配色方案
px像素转换rem单位工具
(支付宝)给作者钱财以资鼓励 (微信)→
有过 279 条评论 »
怎么用纯css实现和按钮一样的点击一次,然后改变样式?听说是用伪元素target,不过我不知道怎么操作 visited的方法前面的小伙伴已经讲了;那我还是帮你搞懂伪元素 target 的用法吧。学东西毕竟得踏踏实实,搞懂想要的再去学新的。:target伪选择器指定的ID匹配上时,它的样式就会在这个ID元素上生效。
CSS里的:target伪选择器
:target是CSS里一个非常有趣的伪选择器。它在CSS里发生效力的过程是这样的:当浏览器地址里的hash(地址里#号后面的部分)和:target伪选择器指定的ID匹配上时,它的样式就会在这个ID元素上生效。让我们看一看这个:target伪选择器是如何起作用的:
观看演示
HTML代码
下面的两个HTML元素上我们都指定了ID:
<h2 id="section1">Section 1</h2> <h2 id="section2">Section 2</h2>
注意上面元素的ID值,当:target指定的ID和window.location.hash值一致时,伪选择器的样式将会生效。
CSS代码
:target伪选择器可以配合CSS类、网页标记和任何其它CSS选择器使用: /* would apply to all targetted elements */ :target { color: #000; } /* applies to H2's */ h2:target { color: #f00; }
当window.location.hash是”section2″时,ID为”section2″的元素将会变红,并显示下划线。简单吧!很像使用了CSS动画技术,你甚至可以在这种效果上做出动画。
:target非常有趣,但我们还没有发现多少人使用这种技术。其实,如果不是太注重动态效果,使用这种浏览器原生技术来修饰你的应用是不错的选择。
//----------------------------解决兼容性方法------------------------------------------------------------ //获取元素的计算后样式属性 function getStyle(element, attr) { if(element.currentStyle) { return element.currentStyle[attr]; } else { return window.getComputedStyle(element, null)[attr]; } } //scroll().top or scroll().left获取已经滚动到元素的左边界或上边界的像素数 function scroll() { return { top: window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0, left: window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0 }; } //获取可视窗口大小 function client() { return { width: window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth || 0, height: window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || 0 }; } //event兼容 var eventCompatible = { //event兼容 getEvent: function(event) { return event || window.event; }, //阻止冒泡事件 stopPropagation: function(event) { var event = event || window.event; if(event && event.stopPropagation) { return event.stopPropagation(); } else { return event.cancelBubble = true; } }, //event.target 事件的目标 (事件委托) getTarget: function(event) { var event = event || window.event; return event.target ? event.target : event.srcElement; }, //鼠标页面坐标 page: function(event) { var event = event || window.event; return { x: event.pageX || event.clientX + document.documentElement.scrollLeft, y: event.pageY || event.clientY + document.documentElement.scrollTop }; }, //阻止默认行为 prevent: function(event){ var event = event || window.event; if (event.preventDefault) { return event.preventDefault(); }else{ return event.returnValue = false; } } }; //监听事件兼容处理 function eventListener(obj, type, handler, unbind) { if(unbind === true) { if(obj.removeEventListener) { obj.removeEventListener(type, handler); } else { obj.detachEvent("on" + type, handler); }; } else { if(obj.addEventListener) { obj.addEventListener(type, handler); } else { obj.attachEvent("on" + type, handler); }; }; }; //清除选择 function clearSelection() { return window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty(); } //--------------------------------------------------------------------------------------- //-----------------------自定义的方法------------------------------------------------ // trim function trim(str) { return str.replace(/^\s+|\s+$/g, ""); } //十进制转其他进制 type类型有"bit"、"oct"、"hex" function changeFromDec(type, value) { var arr = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"] var scale = 0; var sys = ""; if(!/^[\d]*$/g.test(value)) { return ""; } if(!value) { return ""; } if(type === "bit") { scale = 2; } else if(type === "oct") { scale = 8; } else if(type === "hex") { scale = 16; while(true) { sys = arr[value % 16] + sys; value = parseInt(value / 16); if(!value) { break; } } return sys; } while(true) { sys = value % scale + sys; value = parseInt(value / scale); if(!value) { break; } } return sys; } //二进制、八进制、十六进制转十进制; function toDec(type, value) { if(typeof value === "number") value += ""; var scale = 0; var flag = false; if(type === "bit") { flag = /^[01]*$/g.test(value); scale = 2; } else if(type === "oct") { flag = /^[0-7]*$/g.test(value) scale = 8; } else if(type === "hex") { flag = /^[0-9a-fA-F]*$/g.test(value) scale = 16; } if(!flag || !value) return; var arr = value.split(""); var dec = 0; for(var i = 0; i < arr.length; i++) { if(isNaN(parseInt(arr[i]))) { var charCode = arr[i].charCodeAt(0); if(charCode > 64 && charCode < 71) { dec += (charCode - 55) * Math.pow(scale, arr.length - 1 - i) } else if(charCode > 96 && charCode < 103) { dec += (charCode - 87) * Math.pow(scale, arr.length - 1 - i) } } else { dec += arr[i] * Math.pow(scale, arr.length - 1 - i); } } return dec; } //转动时钟 function clock() { var d = new Date(); var ms = d.getMilliseconds(); var s = d.getSeconds() + ms / 1000; var m = d.getMinutes() + s / 60; var h = d.getHours() + m / 60; second.style.transform = "rotate(" + s * 6 + "deg)"; minute.style.transform = "rotate(" + m * 6 + "deg)"; hour.style.transform = "rotate(" + h * 30 + "deg)"; } //匀速动画 function animate(obj, attr, distance) { var step = 20; var leader = parseInt(getStyle(obj, attr)) || 0 clearInterval(obj.atimer); obj.atimer = setInterval(function() { distance > leader ? leader += step : leader -= step; if(Math.abs(distance - leader) > step) { obj.style[attr] = leader + "px"; } else { obj.style[attr] = distance + "px"; clearInterval(obj.atimer); } }, 15); } //缓动动画(单个数值属性) function slowSpeedAnimate(element, attr, distance) { clearInterval(element.timer); element.timer = setInterval(function() { var removing = parseInt(getStyle(element, attr)) || 0; //element.offsetLeft; var step = (distance - removing) / 20; step = step > 0 ? Math.ceil(step) : Math.floor(step); removing = removing + step; element.style[attr] = removing + "px"; if(removing == distance) { clearInterval(element.timer); } }, 15) } //缓动动画(多个数值属性) function moreAnimate(element, json, interval, fn) { clearInterval(element.timer); element.timer = setInterval(function() { var flag = true; for(var k in json) { if(k === "opacity") { var removing = getStyle(element, k) * 100; //element.offsetLeft; var distance = json[k] * 100; var step = (distance - removing) / interval; step = step > 0 ? Math.ceil(step) : Math.floor(step); removing = removing + step; element.style[k] = removing / 100; } else { var removing = parseInt(getStyle(element, k)) || 0; //element.offsetLeft; var distance = json[k]; var step = (distance - removing) / interval; step = step > 0 ? Math.ceil(step) : Math.floor(step); removing = removing + step; element.style[k] = removing + "px"; } if(removing != distance) { flag = false; } } if(flag) { clearInterval(element.timer); if(fn) { fn(); } } }, 15) } //进度条 function Progress(id, width, height, outClass, inClass) { this.width = width; this.height = height; this.color = "#fff"; this.progress = document.createElement("div"); this.percentage = document.createElement("div"); this.filler = document.createElement("div"); var element = document.getElementById(id); if(width) { this.progress.style.width = this.width + "px"; } else { this.progress.style.width = "200px"; } if(height) { this.progress.style.height = this.height + "px"; } else { this.progress.style.height = "20px"; } if(typeof outClass === "string" && (/^[a-zA-Z](\w|[-])+$/g.test(outClass))) { this.progress.className = outClass; } else { this.progress.style.border = "1px solid #cccccc"; this.progress.style.backgroundImage = "linear-gradient(to bottom, #ccc 0%, #fff 40%, #ccc 100%)"; this.progress.style.borderRadius = "10px"; } this.progress.style.overflow = "hidden"; this.progress.style.position = "relative"; element.appendChild(this.progress); // this.progress.appendChild(this.percentage); this.percentage.style.width = "100%"; this.percentage.style.height = "100%"; this.percentage.style.textAlign = "center"; this.percentage.style.position = "absolute"; this.percentage.innerHTML = "0%"; // this.progress.appendChild(this.filler); this.filler.style.height = "100%"; this.filler.style.width = 0; if(typeof inClass === "string" && (/^[a-zA-Z](\w|[-])+$/g.test(inClass))) { this.filler.className = inClass; } else { this.filler.style.backgroundColor = "#DC7BBE"; this.filler.style.backgroundImage = "linear-gradient(to bottom, #0AF 0%, #0ff 40%, #0AF 100%)"; } } Progress.prototype.fill = function(value) { if(value) { this.percentage.innerHTML = value + "%"; this.percentage.style.color = this.color; value = (this.progress.offsetWidth - 2) / 100 * value; this.filler.style.width = value + "px"; } else { this.filler.style.width = 0; this.percentage.innerHTML = "0%"; } } //ajax封装 function ajax(a, b) { //type, url, async, dataType, data, fn var xhr = null, type = "get", url = "#", async = true, dataType = "text", data = "", jsonp = "", jsonpCallback = "", methodName = "", c = null; if(typeof a === "string") { url = a; } if(typeof a === "object") { c = a; } else if(typeof b == "object") { c = b; } if(c) { if(c.type && typeof c.type === "string") { type = c.type; }; if(c.url && typeof c.url === "string") { url = c.url; }; if(c.async && typeof c.async === "boolean") { async = c.async; }; if(c.dataType && typeof c.dataType === "string") { dataType = c.dataType; }; if(c.data && typeof c.data === "object") { var arr = []; for(k in c.data) { arr.push(k + "=" + c.data[k]); } data = arr.join("&"); }; if(c.jsonp && typeof c.jsonp === "string") { if(!c.dataType) { dataType = "jsonp"; } jsonp = c.jsonp; if(data) { data += "&"; } } else { jsonp = "callback"; } if(c.jsonpCallback && typeof c.jsonpCallback === "string") { methodName = c.jsonpCallback; } else { methodName = "jquery" + new Date().getTime() + "_" + (Math.random() + "").substr(2); } }; if(dataType == "jsonp") { data += jsonp + "=" + methodName; window[methodName] = function(data) { c.success(data); } var script = document.createElement("script"); script.src = url + "?" + data; var head = document.getElementsByTagName("head")[0]; head.appendChild(script); } else { //ajax部分 if(window.XMLHttpRequest) { xhr = new XMLHttpRequest(); } else { xhr = ActiveXObject("Microsoft.XMLHTTP"); } if(type == "get") { if(data) { url += encodeURI("?" + data); } data = null; }; xhr.open(type, url, async); if(type == "post") { xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); }; xhr.send(data); xhr.onreadystatechange = function() { if(xhr.readyState == 4 && xhr.status == 200) { var obj = { text: xhr.responseText, json: JSON.parse(xhr.responseText), }; var data = obj[dataType]; if(typeof c.success === "function") { c.success(data); } } } } } //millisec是距离 GMT 时间 1970 年 1 月 1 日午夜的毫秒数 (解析通过ajax返回的数据中的毫秒数值的日期) function getFullDate(millisec, lang) { var data = new Date(); data.setTime(millisec); var year = data.getFullYear(), month = data.getMonth(), day = data.getDate(), week = data.getDay(), hour = data.getHours(), minute = data.getMinutes(), second = data.getSeconds(), am = "am", pm = "pm", enWeek = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], cnWeek = ["星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"], enMonth = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], cnMonth = ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"], cnDay = ["廿", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十"] if(lang == "cn") { am = "上午"; pm = "下午"; }; day = day < 10 ? "0" + day : day; var obj = { year: year, month: lang ? (lang == "cn" ? cnMonth[month] : enMonth[month]) : (month < 10 ? "0" + (month + 1) : (month + 1)), day: day, week: lang == "en" ? enWeek[week] : cnWeek[week], hour: hour < 10 ? "0" + hour : hour, minute: minute < 10 ? "0" + minute : minute, second: second < 10 ? "0" + second : second, ms: data.getMilliseconds(), am: am, pm: pm, Hour: hour + minute / 60 > 12 ? (hour == 12 ? pm + hour : pm + hour % 12) : am + hour, }; return obj; } //右键菜单 function RightMenu(area) { this.area = area; this.menu = null; } //根据传入的值获取目标 RightMenu.prototype.target = function(area) { if(typeof area === "string") { return document.getElementById(area); } else if(typeof area === "object") { return area; } } RightMenu.prototype.init = function(data, defaultStyle, userStyle, hoverStyle) { this.createMenu(data, defaultStyle, userStyle, hoverStyle); this.showMenu(); } RightMenu.prototype.createMenu = function(data, defaultStyle, userStyle, hoverStyle) { if(typeof defaultStyle == "string" && !defaultStyle) { hoverStyle = userStyle; userStyle = defaultStyle; defaultStyle = true; } //创建菜单及样式 this.menu = document.createElement("ul"); this.menu.style.position = "absolute"; this.menu.style.margin = 0; this.menu.style.padding = "2px"; this.menu.style.listStyle = "none"; this.menu.style.display = "none"; if(!defaultStyle) { this.menu.style.border = "1px solid #DDDDDD"; this.menu.style.backgroundColor = "#CCCCCC"; this.menu.style.boxShadow = "5px 5px 5px #ccc"; } else { this.menu.className = userStyle; } //选中项样式 var hover = document.createElement("span"); hover.style.display = "block"; hover.style.position = "absolute" hover.style.top = 0; hover.style.left = 0; hover.style.boxSizing = "border-box"; hover.style.width = "100%"; hover.style.height = "100%"; if((!defaultStyle) || (defaultStyle && !hoverStyle)) { hover.style.border = "1px solid #aaa"; hover.style.borderRadius = "5px"; hover.style.backgroundImage = "linear-gradient(to bottom,rgba(255,255,255,0.5)0%,rgba(255,255,255,0.1)50%,rgba(255,255,255,0.1)100%)"; } else { hover.className = hoverStyle; } //创建菜单项 for(var item in data) { var li = document.createElement("li"); li.style.position = "relative"; li.style.padding = "5px 10px"; li.style.cursor = "pointer"; //绑定事件 li.addEventListener("mouseenter", function() { this.appendChild(hover); }); li.addEventListener("mouseleave", function() { this.removeChild(hover); }); var itemData = data[item] for(var obj in itemData) { if(typeof itemData[obj] === "string") { li.innerHTML = itemData[obj]; } else if(typeof itemData[obj] === "object") { var handlerData = itemData[obj]; for(var type in handlerData) { li.addEventListener(type, handlerData[type]); } } } this.menu.appendChild(li); } this.target(this.area).appendChild(this.menu); } RightMenu.prototype.showMenu = function() { var that = this; this.menu.parentNode.oncontextmenu = function(ev) { that.menu.style.display = "block"; that.menu.style.left = ev.pageX + "px"; that.menu.style.top = ev.pageY + "px"; if(that.menu.parentNode.offsetWidth < that.menu.offsetLeft + that.menu.offsetWidth) { that.menu.style.left = ev.pageX - that.menu.offsetWidth + "px"; }; if(that.menu.parentNode.offsetHeight < that.menu.offsetTop + that.menu.offsetHeight) { that.menu.style.top = ev.pageY - that.menu.offsetHeight + "px"; }; return false; } this.menu.parentNode.onclick = function() { that.menu.style.display = "none"; } document.onkeydown = function(e) { if(e.keyCode == 18 || e.keyCode == 27) { that.menu.style.display = "none"; } } } //拖拽 function Drag(target, area) { this.target = target; this.area = area; } //根据传入的值获取目标 Drag.prototype.dragTarget = function(target) { if(typeof target === "string") { return document.getElementById(target); } else if(typeof target === "object") { return target; } } Drag.prototype.init = function() { this.target = this.dragTarget(this.target); this.target.style.position = "absolute"; this.target.setAttribute("draggable","true"); this.dragEvent(); } Drag.prototype.dragEvent = function() { var that = this; this.target.onmousedown = function(e) { e = e || window.event; that.disX = e.clientX - that.target.offsetLeft; that.disY = e.clientY - that.target.offsetTop; document.onmousemove = function(e) { that.moveEvent(e); } document.onmouseup = function(){ that.target.style.opacity = "1"; document.onmousemove = document.onmouseup = null; } return false; } } Drag.prototype.moveEvent = function(e) { var limitX = e.clientX - this.disX; var limitY = e.clientY - this.disY; //没有指定区域则用document if (!this.area) { this.area = document.documentElement; } if(limitX < this.area.offsetLeft) { limitX = this.area.offsetLeft; } else if(limitX > this.area.clientWidth + this.area.offsetLeft - this.target.offsetWidth) { limitX = this.area.clientWidth + this.area.offsetLeft - this.target.offsetWidth; } if(limitY < this.area.offsetTop) { limitY = this.area.offsetTop; } else if(limitY > this.area.clientHeight + this.area.offsetTop - this.target.offsetHeight) { limitY = this.area.clientHeight + this.area.offsetTop - this.target.offsetHeight; } this.target.style.left = limitX + "px"; this.target.style.top = limitY + "px"; this.target.style.opacity = "0.8"; }
input {-webkit-appearance:none; border-radius: 0; /*去除input默认样式*/} input[type="submit"], input[type="reset"], input[type="button"], input{-webkit-appearance:none;}
div{ word-break:break-all; }
CSS3的一些前缀总结
-webkit /*为Chrome/Safari*/ -moz /*为Firefox*/ -ms /*为IE*/ -o /*为Opera*/ -webkit-transform:rotate(-3deg); /*为Chrome/Safari*/ -moz-transform:rotate(-3deg); /*为Firefox*/ -ms-transform:rotate(-3deg); /*为IE*/ -o-transform:rotate(-3deg); /*为Opera*/ transform:rotate(-3deg); /*为nothing*/ -moz-border-radius: 12px; /* FF1-3.6 */ -webkit-border-radius: 12px; /* Saf3-4, iOS 1-3.2, Android <1.6 */ border-radius: 12px; /* Opera 10.5, IE9, Saf5, Chrome, FF4, iOS 4, Android 2.1+ */
css3的box-sizing
给了两个并排带边框的div百分比宽度,假如不用box-sizing,边框的宽度会在行内显示。用box-sizing:border-box,可以去除边框的占位。
浏览器支持IE9以上及火狐、谷歌、Opera等等。
模糊遮罩效率,模糊滤镜效果
-webkit-filter: blur(3px); -moz-filter: blur(3px); -o-filter: blur(3px); -ms-filter: blur(3px); filter: blur(3px);
下载文件重命名.rar压缩包解压即可
google-404.rar
<script language="javascript"> document.write("js获取当前域名"+window.location.host+"或者"+document.domain+"<br>"); document.write("js获取当前url"+window.location.href+"<br>"); document.write("js获取上(前)一页url"+document.referrer); </script>
使用Javascript改变HTML内容
document.getElementById("mySpan").innerHTML = "我是被JS改变后的内容";
PHPExcel_IOFactory' not found
php excel导入数据库
没有命名空间,所以声明实例的时候一定要加根符号,$phpexcel = new \PHPExcel();
在所有的调用前都加上命名空间 '\'
$objPHPExcel = \PHPExcel_IOFactory::load($filename);
/ThinkPHP/Library/Vendor/PHPExcel
function daorudata(){ $new_text='请上传Excel文件'; if(! empty ( $_FILES ['file_stu'] ['name'] )){ $file = $_FILES ['file_stu'] ['tmp_name']; $file_types = explode ( ".", $_FILES ['file_stu'] ['name'] ); $file_type = $file_types [count ( $file_types ) - 1]; /*判别是不是.xls文件,判别是不是excel文件*/ if (strtolower ( $file_type ) != "xls"){ $new_text='不是Excel文件,重新上传'; //exit; } else{ // 判断文件是什么格式 $type = pathinfo($file); $type = strtolower($type["extension"]); $type=$type==='csv' ? $type : 'Excel5'; ini_set('max_execution_time', '0'); Vendor('PHPExcelN.PHPExcel'); // 判断使用哪种格式 $objReader = \PHPExcel_IOFactory::createReader($type); $objPHPExcel = $objReader->load($file); $sheet = $objPHPExcel->getSheet(0); // 取得总行数 $highestRow = $sheet->getHighestRow(); // 取得总列数 $highestColumn = $sheet->getHighestColumn(); //循环读取excel文件,读取一条,插入一条 $data=array(); //从第一行开始读取数据 //dump($data); for($j=2;$j<=$highestRow;$j++){ //从A列读取数据 //for($k='A';$k<=$highestColumn;$k++){ // 读取单元格 $k='A'; if($objPHPExcel->getActiveSheet()->getCell("$k$j")->getValue()){ $data[$j][]=$objPHPExcel->getActiveSheet()->getCell("$k$j")->getValue(); $vsfsd=$objPHPExcel->getActiveSheet()->getCell("$k$j")->getValue(); $newdr[$k]['tel']=$vsfsd; $pass=str_split('0'.$vsfsd,6); $newdr[$k]['pass']=$pass['1']; $daoruok=$this->ree($newdr[$k]['tel'],$newdr[$k]['pass']); //成功注册 /*if($daoruok){ $daoruokstr.='成功注册'.$newdr[$k]['tel'].'<br>'; }else{ $daoross.='导入失败'.$newdr[$k]['tel'].'<br>'; }*/ $daoross.=$newdr[$k]['tel'].'<br>'; if($j==$highestRow) $daoross.='会员数据导入结束。<br>'; //$this->display (); } //} } //dump($data); $new_text='正在导入中...'; //return $data; } } $this->assign ( 'daoruokstr', $daoruokstr ); $this->assign ( 'daoross', $daoross ); $this->assign ( 'new_text', $new_text ); $this->display (); }
function ree($tel,$pass){ $mapc['tel']=$tel; $s_tel=M('huiyuan')->where($mapc)->limit(0,1)->select(); $s_tel=($s_tel['0']['id']); if($s_tel) return false; //写入注册信息 $data ['token'] = get_token (); //$data['rip']=$this->getip(); $data['tel']=$tel;//$_SESSION['check_mobile'];//$_POST['tel']; $salt=$this->generate_rand(9);//rand(100000,999999); $data['salt']=$salt; $data['pass']=md5($pass.$salt); $data['cTime']=time(); $data['mTime']=$data['cTime']; $saltr=$this->generate_rand(9); $data['saltr']=$saltr; //$data['lip']=$data['rip']; $data['zcj']=0;//$_SESSION['guanzhu_choujiang']; //$data['logg']=md5($data['rip'].$data['saltr']);//md5($data['rip'].$data['mTime'].$data['saltr']); //注册送抽奖次数 //$nnpn=($this->config); //$nnpn=$nnpn['cjzss']+0; //$nnpncjzssdd=($this->config); //$nnpncjzssdd=$nnpncjzssdd['cjzssdd']+0; //$data['dtime']=date('Ymd'); //if($nnpn) $data['zcj']=$_SESSION['guanzhu_choujiang']+$nnpn;//$_SESSION['guanzhu_choujiang']+$nnpn; $res = M('Huiyuan')->add($data); if($res){ //echo '成功注册 '.$tel.'<br />'; } }
判断是否登录
if (! is_login ()) { redirect ( U ( 'home/user/login', array ( 'from' => 2 ) ) ); }
任意环境下调试php,debug php
在不管php.ini配置的情况下开启php调试,php debug.
在你需要调试的php文件首行中加入.
ini_set('display_errors',1); //错误信息 ini_set('display_startup_errors',1); //php启动错误信息 error_reporting(-1); //打印出所有的 错误信息 ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); //将出错信息输出到一个文本文件
开发环境调试php,debug php php.ini 配置
;显示错误信息 display_errors = On ;显示php开始错误信息 display_startup_errors = On ;日志记录错误信息 log_errors = On
参考文档
thinkphp整合系列之phpexcel导入excel数据
<a href="javascript: alert('test');">