javascriptÅжϱäÁ¿ÀàÐ͵Ä×Ô¶¨Ò庯Êý
ͨ³£ÓÃtypeofÀ´ÅжÏjs±äÁ¿µÄÀàÐÍ£¬µ«ºÜ¶àʱºò½ö½ötypeofÂú×ã²»ÁËÒªÇóµÄ¡£
ÎÒдÁËÒ»¸ö×Ô¶¨Ò庯ÊýÀ´×öÕâ¸öÊ£¬ÅжϵıȽÏÈ«ÃæÁË¡£
New
function
varType(v){
if
(
typeof
v===
"object"
){
if
(v===
null
)
return
'null'
;
if
(v.
constructor
)
return
(v.
constructor
.toString()).match(/(?:
)[\w\$]+/)[
0
];
if
(
typeof
typeof2===
'undefined'
&&
window
.execScript){
window
.execScript(
'Function vbsTypeName(o):vbsTypeName=TypeName(o):End
Function'
,
'vbscript'
);
window
.execScript(
'function typeof2(o){return vbsTypeName(o)}'
,
'jscript'
);
}
if
(
typeof
typeof2!==
'undefined'
){
return
typeof2(v);
}
return
"object"
;
}
return typeof
v;
}
//¶ÔÓÚÆÕͨjs³£Á¿ºÍjs¶ÔÏ󣬸÷ä¯ÀÀÆ÷ÊÇ»ù±¾Ò»ÖµÄ
alert
(varType());
//undefined
alert
(varType(
100
));
//number
alert
(varType({}));
//Object
alert
(varType([]));
//Array
alert
(varType(/ /));
//RegExp
alert
(varType(
new
Date
()));
//Date
alert
(varType(
Date
));
//function
alert
(varType(
Object
));
//function
alert
(varType(
RegExp
));
//function
//¶ÔÓÚDOM¶ÔÏ󣬸÷ä¯ÀÀÆ÷¿ÉÄÜ»áÓв»Í¬Öµ
alert
(varType(
window
));
//IE:HTMLWindow2 FF:Window
alert
(varType(
document
));
//IE:HTMLDocument FF:HTMLDocument
alert
(varType(
document
.body));
//IE:HTMLBody FF:HTMLBodyElement
alert
(varType(
Option
));
//IE:Object FF:function
alert
(varType(
Image
));
//IE:Object FF:function
alert
(varType(
navigator
));
//IE:DispHTMLNavigator FF:Navigator
//ÒÔϼ¸¸öÖ»ÊÊÓÃÓÚIE£¬ÆäËûÄÚºËä¯ÀÀÆ÷²»Ö§³Ö
alert
(varType(
ActiveXObject
));
//IE:function
alert
(varType(
Ïà¹ØÎĵµ£º
Ò». »ù´¡Æª
1. Javascriptѧϰ±Ê¼Ç1——Êý¾ÝÀàÐÍ
2. Javascriptѧϰ±Ê¼Ç2——º¯Êý
3. Javascriptѧϰ±Ê¼Ç3——×÷ÓÃÓò
4. Javascriptѧϰ±Ê¼Ç4——Evalº¯Êý
5. Javascriptѧϰ±Ê¼ ......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>JavaScriptÄ£¿éË ......
/**
* ×Ô¼ºµÄ HashTable
* Ô¸½Å±¾ÉñÁ¦ÓëÄãͬÔÚ
*/
function HashTable(){
var values = {};
/** ½«Öµ²åÈë HashTable ÖÐ **/
this.put = function(key, value){
if(key in values){
return false;
}
values[key] = value;
}
/** ¸ù¾Ý key ·µ»Ø value **/
this.find = function(key){
ret ......
1. oncontextmenu="window.event.returnValue=false" ½«³¹µ×ÆÁ±ÎÊó±êÓÒ¼ü
<table border oncontextmenu=return(false)><td>no</table> ¿ÉÓÃÓÚTable
2. <body onselectstart="return false"> È¡Ïûѡȡ¡¢·ÀÖ¹¸´ÖÆ
3. onpaste="return false" ²»×¼Õ³Ìù
4. oncopy="return false;" oncut="return f ......