javascript小技巧(转)
来源:互联网 发布:ubuntu 改变用户组 编辑:程序博客网 时间:2024/06/08 16:48
<textarea cols="50" rows="15" name="code" class="javascript"># 事件源对象event.srcElement.tagNameevent.srcElement.type# 捕获释放event.srcElement.setCapture(); event.srcElement.releaseCapture(); # 事件按键event.keyCodeevent.shiftKeyevent.altKeyevent.ctrlKey# 事件返回值event.returnValue# 鼠标位置event.xevent.y# 窗体活动元素document.activeElement# 绑定事件document.captureEvents(Event.KEYDOWN);# 访问窗体元素document.all("txt").focus();document.all("txt").select();# 窗体命令document.execCommand# 窗体COOKIEdocument.cookie# 菜单事件document.oncontextmenu# 创建元素document.createElement("SPAN"); # 根据鼠标获得元素:document.elementFromPoint(event.x,event.y).tagName=="TDdocument.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)# 替换CSSdocument.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" mce_href="mailto:aaa@bbb.com?subject=ccc&body=xxxyyy"> # 快速转到位置obj.scrollIntoView(true)# 锚<a name="first"><a href="#first" mce_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" mce_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="javascript:function()" mce_href="javascript:function()">word</a># 上一网页源asp:request.servervariables("HTTP_REFERER")javascript:document.referrer# 释放内存CollectGarbage();# 禁止右键document.oncontextmenu = function() { return false;}# 禁止保存<noscript><iframe src="*.htm" mce_src="*.htm"></iframe></noscript># 禁止选取<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 onpaste="return false"># 地址栏图标<link rel="Shortcut Icon" href="favicon.ico" mce_href="favicon.ico">favicon.ico 名字最好不变16*16的16色,放虚拟目录根目录下# 收藏栏图标<link rel="Bookmark" href="favicon.ico" mce_href="favicon.ico"># 查看源码<input type=button value=查看网页源代码 onclick="window.location = 'view-source:'+ 'http://www.csdn.net/'"># 关闭输入法<input style="ime-mode:disabled" mce_style="ime-mode:disabled"># 自动全选<input type=text name=text1 value="123" onfocus="this.select()"># ENTER键可以让光标移到下一个输入框<input onkeydown="if(event.keyCode==13)event.keyCode=9"># 文本框的默认值<input type=text value="123" onfocus="alert(this.defaultValue)"># title换行obj.title = "123sdfs "# 获得时间所代表的微秒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)" mce_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 onload="window.resizeTo(window.screen.width - 4,window.screen.height-50);window.moveTo(-4,-4)"># 无关闭按钮IEwindow.open("aa.htm", "meizz", "fullscreen=7");# 统一编码/解码alert(decodeURIComponent(encodeURIComponent("http://你好.com?as= hehe")))encodeURIComponent对":"、"/"、";" 和 "?"也编码# 表格行指示<tr onmouseover="this.bgColor='#f0f0f0'" onmouseout="this.bgColor='#ffffff'"> </textarea>
http://www.blogguy.cn/show-43-1.html
- javascript小技巧 (转)
- [转]JavaScript小技巧
- javascript小技巧[转]
- javascript小技巧[转]
- 转 JAVASCRIPT 小技巧
- javascript小技巧[转]
- javascript小技巧[转]
- javascript小技巧[转]
- JAVASCRIPT 小技巧 [转]
- JAVASCRIPT 小技巧 [转]
- javascript小技巧[转]
- javascript小技巧[转]
- javascript小技巧[转]
- javascript小技巧[转]
- javascript小技巧[转]
- javascript小技巧 [转]
- [转] javascript小技巧
- [转]JavaScript小技巧
- Java异常处理机制的详细讲解和使用技巧
- 带参数运行应用程序
- WEB-INF中访问受限制的JSP页面的访问方法
- 平台型OA定制开发的优势所在
- ASP.NET中数据库的操作初步----DataSet操作数据库
- javascript小技巧(转)
- FD_SET
- 企业级应用软件的开发到底有多难
- java 抓取网页内容
- ASP.NET中数据库操作初步
- Wince 同步更新任务栏时间
- 改进Source Insight对汉字的支持
- 关于IBM刀片服务器
- Android学习笔记--state list