PC-JS小技巧
# 事件源对象
event.srcElement.tagName
event.srcElement.type
# 捕获释放
event.srcElement.setCapture();
event.srcElement.releaseCapture();
# 事件按键
event.keyCode
event.shiftKey
event.altKey
event.ctrlKey
# 事件返回值
event.returnValue
# 鼠标位置
event.x
event.y
# 窗体活动元素
document.activeElement
# 绑定事件
document.captureEvents(Event.KEYDOWN);
# 访问窗体元素
document.all(“txt”).focus();
document.all(“txt”).select();
# 窗体命令
document.execCommand
# 窗体 COOKIE
document.cookie
# 菜单事件
document.oncontextmenu
# 创建元素
document.createElement(“SPAN”);
# 根据鼠标获得元素:
document.elementFromPoint(event.x,event.y).tagName==”TD
document.elementFromPoint(event.x,event.y).appendChild(ms)
# 窗体图片
document.images[索引]
# 窗体事件绑定
document.onmousedown=scrollwindow;
# 元素
document.窗体.elements[索引]
# 对象绑定事件
document.all.xxx.detachEvent(‘onclick’,a);
# 插件数目
navigator.plugins
# 取变量类型
typeof($js_libpath) == “undefined”
# 下拉框
下拉框.options[索引]
下拉框.options.length
# 查找对象
document.getElementsByName(“r1″);
document.getElementById(id);
# 定时
timer=setInterval(‘scrollwindow()’,delay);
clearInterval(timer);
# UNCODE编码
escape() ,unescape
# 父对象
obj.parentElement(dhtml)
obj.parentNode(dom)
# 交换表的行
TableID.moveRow(2,1)
# 替换CSS
document.all.csss.href = “a.css”;
# 并排显示
display:inline
# 隐藏焦点
hidefocus=true
# 根据宽度换行
style=”word-break:break-all”
# 自动刷新
<meta HTTP-EQUIV=”refresh” CONTENT=”8;URL=http://c98.yeah.net”>
# 简单邮件
<a href=”mailto:aaa@bbb.com?subject=ccc&body=xxxyyy”>
# 快速转到位置
obj.scrollIntoView(true)
# 锚
<a name=”first”>
<a href=”#first”>anchors</a>
# 网页传递参数
location.search();
# 可编辑
obj.contenteditable=true
# 执行菜单命令
obj.execCommand
# 双字节字符
/[^\x00-\xff]/
汉字
/[\u4e00-\u9fa5]/
# 让英文字符串超出表格宽度自动换行
word-wrap: break-word; word-break: break-all;
# 透明背景
<IFRAME src=”1.htm” width=300 height=180 allowtransparency></iframe>
# 获得style内容
obj.style.cssText
# HTML标签
document.documentElement.innerHTML
# 第一个style标签
document.styleSheets[0]
# style标签里的第一个样式
document.styleSheets[0].rules[0]
# 防止点击空链接时,页面往往重置到页首端。
<a href=”javascrīpt:function()”>word</a>
# 上一网页源
asp:
request.servervariables(“HTTP_REFERER”)
javascrīpt:
document.referrer
# 释放内存
CollectGarbage();
# 禁止右键
document.oncontextmenu = function() { return false;}
# 禁止保存
<noscrīpt><iframe src=”*.htm”></iframe></noscrīpt>
# 禁止选取<body oncontextmenu=”return false” ondragstart=”return false” onselectstart =”return false” onselect=”document.selection.empty()” oncopy=”document.selection.empty()” onbeforecopy=”return false”onmouseup=”document.selection.empty()>
# 禁止粘贴
<input type=text ōnpaste=”return false”>
# 地址栏图标
<link rel=”Shortcut Icon” href=”favicon.ico”>
favicon.ico 名字最好不变16*16的16色,放虚拟目录根目录下
# 收藏栏图标
<link rel=”Bookmark” href=”favicon.ico”>
# 查看源码
<input type=button value=查看网页源代码 ōnclick=”window.location = ‘view-source:’+ ‘http://www.csdn.net/'”>
# 关闭输入法
<input style=”ime-mode:disabled”>
# 自动全选
<input type=text name=text1 value=”123″ ōnfocus=”this.select()”>
# ENTER键可以让光标移到下一个输入框
<input ōnkeydown=”if(event.keyCode==13)event.keyCode=9″>
# 文本框的默认值
<input type=text value=”123″ ōnfocus=”alert(this.defaultValue)”>
# title 换行
obj.title = “123
sdfs ″
# 获得时间所代表的微秒
var n1 = new Date(“2004-10-10″.replace(/-/g, “\/”)).getTime()
# 窗口是否关闭
win.closed
# checkbox扁平
<input type=checkbox style=”position: absolute; clip:rect(5px 15px 15px 5px)”><br>
# 获取选中内容
document.selection.createRange().duplicate().text
# 自动完成功能
<input type=text autocomplete=on>打开该功能
<input type=text autocomplete=off>关闭该功能
# 窗口最大化
<body ōnload=”window.resizeTo(window.screen.width – 4,window.screen.height-50);window.moveTo(-4,-4)”>
# 无关闭按钮IE
window.open(“aa.htm”, “meizz”, “fullscreen=7″);
# 统一编码/解码
alert(decodeURIComponent(encodeURIComponent(“http:// 你好.com?as= hehe”)))
encodeURIComponent对”:”、”/”、”;” 和 “?”也编码
# 表格行指示
<tr ōnmouseover=”this.bgColor=’#f0f0f0′” ōnmouseout=”this.bgColor=’#ffffff'”>
PC-JS小技巧的更多相关文章
- [转载]Js小技巧||给input type=“password”的输入框赋默认值
http://www.cnblogs.com/Raywang80s/archive/2012/12/06/2804459.html [转载]Js小技巧||给input type="passw ...
- js小技巧总结
js小技巧总结 1.Array.includes条件判断 function test(fruit) { const redFruits = ["apple", "stra ...
- html/css/js小技巧实例
一些学习中碰到的小技巧 让div自动撑起来: .clearfix:after{ content: "."; clear: both; display: block; visibil ...
- javascript小技巧-js小技巧收集(转)
本文转载自:http://blog.csdn.net/ocean20/article/details/2498699 每一项都是js中的小技巧,但十分的实用! 1.document.write(&qu ...
- JS小技巧大本事(持续更新)
1. 复制N个字符 String.prototype.repeat = function(num){ return (new Array(++num)).join(this); } var a = ' ...
- 可以提升幸福感的js小技巧(下)
4.数字 4.1 不同进制表示法 ES6中新增了不同进制的书写格式,在后台传参的时候要注意这一点. 29 // 10进制 035 // 8进制29 原来的方式 0o35 // 8进制29 ES6的方式 ...
- js小技巧
js判断字符长度 直接使用String对象的属性,空格亦算一个字符 myString = "Hello world"; length = myString.length js比较字 ...
- js 小技巧
如果想让js每次加载时,都要执行, 那么在 <script type="text/javascript" >中加一个属性reload="1", &l ...
- 一些CSS/JS小技巧
CSS部分 1.文本框不可点击 .inputDisabled{ background-color: #eee;cursor: not-allowed;} 2.禁止复制粘贴 onpaste=" ...
- 【JS小技巧】JavaScript 函数用作对象的隐藏问题
用户反馈 @消失的键盘 在论坛反馈了一个问题,在 AppBoxMvc 中的 Title 模型中,如果将 Name 属性改名为小写的 name 属性,就会报错: 因为这是一个 ASP.NET MVC 的 ...
随机推荐
- C#之out与ref的共性与区别以及用法
引入: 首先看一个例子: class Program { static void Main(string[] args) { ; int result = Test(number); Console. ...
- hdu 2033
水题 AC代码: #include <iostream> using namespace std; int main() { int i,j,n,k,a[100],b[100]; cin& ...
- Js 插件修改及优化总结
1. ajaxfileupload 上传插件版本问题以及数据处理问题 参考链接: http://liwx2000.iteye.com/blog/1540321 现在大家至少也在用jquery1.9以上 ...
- Aspose.Cells for .NET 8.5.0 工具类
基于 Aspose.Cells for .NET 8.5.0 工具类, Aspose.Cells for .NET 8.5.0 这个自己去CSDN下载里面有破解的,没有破解的导出excel的时候会(A ...
- MiniUI学习笔记1
1.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.or ...
- SqlServer 数据库进行定时自动的执行脚本
需求:数据库进行自动执行脚本操作,有些数据库操作就不需要写程序来定时执行,完全可以交给我们SqlServer客户端代理来做,下面的步骤,我是结合前一篇文章的SqlServer不同服务器数据库之间数据传 ...
- uva 260 - Il Gioco dell'X
题解: 一定有人获胜,非黑即白:获胜条件为:black是由 上走到下,white是由 左走到右: #include <cstdio> using namespace std; int N; ...
- hdoj 1233 还是畅通工程---最小生成树---prime算法
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1233 可以用Kruskal来做,不过当图的边比较稠密的时候用prime会更快一些. AC代码:296MS ...
- contentInset,contentsize和contentOffset区别
contentInset,contentsize和contentOffset区别 今天看别人用到了contentInset,觉得很迷糊,于是gogle了一下,搜到了一篇分析的很好的文章,转在这里, ...
- 为GCD队列绑定NSObject类型上下文数据-利用__bridge_retained(transfer)转移内存管理权-备
下面评论的好友“@Jim”给了种新的思路,就是在清除context的函数里面,用“_bridge_transfer”转换context,把context的内存管理权限重新交给ARC,这样,就不用显式调 ...