当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 大家未必知道的Js技巧收藏

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 大家未必知道的Js技巧收藏


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 164 ::
收藏到网摘: n/a

1.document.GetElementsByTagName可以获得某一个标签的所有元素,可以通过
document.getElementsByTagName('*')
获得页面上的所有元素,这里星号代表任何标签,而注释标签的tagName是”!”
2.String 的方法substr与substring的区别
substr(start[,length]);//表示从start位置开始取length个字符串
substring(start,end);//表示从start,到end之间的字符串,包括start位置的字符但是不包括end位置的字符
3.“==”与“===”
前者比较两个对象会自动进行类型转换例如比较'12' == 12将返回true;而后者不进行任何转换必须完全相等'12' === 12将返回false
4.如何使网页不可以被保存
<noscript><iframe src=*.html></iframe></noscript><noscript><iframe src=*.html></iframe></noscript>
5.使用document.referrer可以获得上一页的地址
6.使用input元素的form属性可以得到该input所属的form元素
7.Script标签中的defer属性
作用是告诉浏览器可以继续执行html,而不必先执行src指定的js代码,直到发生不能继续执行的情况。
8.通过arguments可以得到传递到当前执行function的所有参数的一个数组,即便你没有给该function定义任何参数。
9.可以使用document.anchors获得页面上面所有的链接元素,而不必使用
document.getElementsByTagName('A');
同样道理还有:
document.forms
document.images
10.使用js判断客户端机器是否安装了.net framework
function hasDotNetFramework(){return navigator.userAgent.indexOf(".NET CLR") > -1;}
11.在客户端事件中使用"代替“””
例如:
var html = '<a href="javascript:alert("this is message")">hello</a>';