常用html、demo代码
发布时间:2015-10-15, 14:45:06 分类:HTML | 编辑 off 网址 | 辅助
图集1/30
正文 9756字数 27,226,765阅读
暗网网址导航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 条评论 »
<strong class="line-thru">或</strong> <style>.line-thru { display: block; font-size: .875em; margin-bottom: 1em; position: relative; text-align: center; width: 100%; z-index: 1; } .line-thru:before { width: 40px; height: 10px; background-color: #fff; content: ''; margin: -5px 0 0 -20px; left: 50%; position: absolute; top: 50%; z-index: -1; } .line-thru:after { border-bottom: 1px solid #dfe0e6; content: ''; display: block; position: absolute; top: 49%; width: 100%; z-index: -2; }</style>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> *{ margin: 0; padding: 0; } .border {width: 1000px;margin: 100px auto;} .border li{width: 100px;height: 100px;display: inline-block;margin: 10px;line-height: 100px;text-align: center;position: relative; -webkit-transform: scale(1); transform: scale(1);} .border li::before { position: absolute; z-index: -1; top: -1px; right: 0; bottom: 1px; left: 0; content: ''; opacity: .5; border: 2px solid; border-radius: 3px; } .red{color:red;} .blue{color:blue;} .orange{color:orange;} </style> </head> <body> <div class="border"> <li class="red">红色</li> <li class="blue">蓝色</li> <li class="orange">橘色</li> </div> </body> </html>
<script src="https://lizhenqiu.com/templates/default/jquery.min.js"></script><script>$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js', function(){ alert(remote_ip_info.country);//国家 alert(remote_ip_info.province);//省份 alert(remote_ip_info.city);//城市 });</script>
bootcss官网有个这个页面
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8" /> <meta name="renderer" content="webkit"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>web安全色</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } html, body { width: 100%; height: 100%; font-size: 12px; background-color: #efefef; } h1 { height: 100px; line-height: 100px; font-size: 36px; text-align: center; } .color-list { display: -webkit-flex; display: -moz-flex; display: -ms-flex; display: -o-flex; display: flex; width: 1000px; margin: 0 auto; justify-content: space-between; align-items: space-between; flex-wrap: wrap; overflow-y: auto; } .color-item { width: 150px; height: 190px; margin-bottom: 20px; border-radius: 8px; border: 1px solid #ccc; box-shadow: 3px 2px 3px #ccc; } .color-block { width: 148px; height: 130px; border-radius: 5px; border-bottom: 1px solid #ccc; } .color-code { height: 36px; line-height: 18px; padding-left: 10px; margin-top: 10px; } .color-code strong { margin-right: 14px; } </style> </head> <body> <h1>WEB安全色DEMO</h1> <div class="color-list" id="color-list"></div> <script> window.onload = () => { let format = (num) => ('0' + num.toString(16)).slice(-2) let arr = [0, 0, 0], dom = [] while (arr[0] <= 5) { let arr2 = arr.map((ele) => ele * 51) let hex = '#' + arr2.map((ele) => format(ele)).join('').toUpperCase(), rgb = arr2.join(', ') arr[2]++ if (arr[2] > 5) { arr[2] = 0 arr[1]++ if (arr[1] > 5) { arr[0]++ arr[1] = 0 } } dom.push(`<div class="color-item"> <div class="color-block" style="background-color: ${hex};"></div> <div class="color-code"> <p><strong>HEX:</strong><span>${hex}</span></p> <p><strong>RGB:</strong><span>${rgb}</span></p> </div></div>`) } document.querySelector('#color-list').innerHTML = dom.join('') setInterval(() => document.querySelector('h1').style.color = '#' + Math.random().toString(16).slice(2, 8), 233) } </script> </body> </html>
在百分比布局中, 使用纯css实现的按照元素寬度的一定比例來設定高度的小技巧(比如寬度占屏幕20%,高度是寬度的100%, 调整宽度,高度会等比缩放),
如果你知道更好的技巧实现它, 欢迎下方留言哦
<!DOCTYPE HTML> <html> <head> <style> .father { width: 20%; /*改一下宽度试试看*/ } .daughter { width: 100%; height: 0; padding-top: 100%; background: #ff7500;; } </style> </head> <body> <div class = "father"> <div class = "daughter"></div> </div>
.bg-img1 { background-image: url(../images/ghfa-bj.jpg); background-size: cover !important; background-position: center center; background-repeat: no-repeat; background-attachment: fixed; }
1. writing-mode(设置对象书写方向)
语法:writing-mode : lr-tb、tb-rl 参数:lr-tb:从左向右,从上往下 tb-rl:从上往下,从右向左 示例:div { writing-mode: tb-rl; }
2. text-align(设置对象中文本的对齐方式)
语法:text-align : left、right、center、justify 参数:left:左对齐 right:右对齐 center:居中 justify:两端对齐 示例:div { text-align : center; }
示例代码
<style>.div { writing-mode: tb-rl; } </style> <div class="div">fdsafasdfads设置css文字居中</div>
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>竖列排版实例 在线演示 www.divcss5.com</title> <style> body{width: 20px;text-align:center; line-height:22px} /* CSS注释说明:设置css文字居中,css行高为22px间隔 */ </style> </head> <body> 我<br>是<br>竖<br>列<br>排<br>版 </body> </html>
<ul> <li>文字</li> <li>文字</li> <li>文字</li> </ul>
maxlength="5",则input输入框中只能够输入5个字符 size="5",表示input输入框只显示5个可见的字符,但你可以输入'无数'多字符内容 即:size属性规定输入字段的宽度(此处即是Name2文本框只显示5个字符大小的宽度), 由于 size 属性是一个可视化的设计属性,我们应使用 CSS 中的width来代替它。 CSS 语法:<input style="width:100px"/> 具体是:用JavaScript来修改该属性. 刚开始在Javascript里面是死活取不出该属性的值,没办法,去网上搜搜吧.没仔细看,就是感觉我跟他们写的没有什么差别啊,我就不信了,还弄不好它?可是就是弄不好 最后,仔细看了网上的一个,发现还真有点问题,我没有大写,书写的时候全是小写字母. readonly <====> readOnly 改成后者以后,还真的好了:)
Select的onchange事件
我们用Select的onchange事件时,常会遇到这样一个问题,那就是连续选相同一项时,不触发onchange事件.select的onchange事件就是这样子的.你得有Change(改变),才能触发该事件....
掌握了它的特性后,相应的解决办法也很简单.
<select name=sel onchange="bao(this.options[this.options.selectedIndex].value)"> <option value="">请选择 <option value="1">Item 1 <option value="2">Item 2 <option value="3">Item 3 </select> <script> function bao(s) { txt.value+=s; //选择后,让第一项被选中,这样,就有Change啦. document.all.sel.options[0].selected=true; } </script> <textarea id=txt></textarea>