JavaScript »ñÈ¡¿Í»§¶Ë¼ÆËã»úÓ²¼þ¼°ÏµÍ³ÐÅÏ¢
JavaScript »ñÈ¡¿Í»§¶Ë¼ÆËã»úÓ²¼þ¼°ÏµÍ³ÐÅÏ¢
ͨ¹ýWMIÀ´ÊµÏÖ»ñÈ¡¿Í»§¶Ë¼ÆËã»úÓ²¼þ¼°ÏµÍ³ÐÅÏ¢:
1//ϵͳÐÅÏ¢»ñÈ¡
2function getSysInfo(){
3 var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
4 var service = locator.ConnectServer(".");
5 //CPUÐÅÏ¢
6 var cpu = new Enumerator (service.ExecQuery("SELECT * from Win32_Processor")).item();
7 var cpuType=cpu.Name,hostName=cpu.SystemName;
8 //ÄÚ´æÐÅÏ¢
9 var memory = new Enumerator (service.ExecQuery("SELECT * from Win32_PhysicalMemory"));
10 for (var mem=[],i=0; !memory.atEnd(); memory.moveNext())
mem[i++]={cap:memory.item().Capacity/1024/1024,speed:memory.item().Speed}
11 //ϵͳÐÅÏ¢
12 var system=new Enumerator (service.ExecQuery("SELECT * from Win32_ComputerSystem")).item();
13 var physicMenCap=Math.ceil(system.TotalPhysicalMemory/1024/1024),curUser=system.UserName,cpuCount=system.NumberOfProcessors
14
15 return {cpuType:cpuType,cpuCount:cpuCount,hostName:hostName,curUser:curUser,memCap:physicMenCap,mem:mem}
16}
´úÂëʵÏÖÖ÷Òª°üÀ¨Õ⼸²¿·Ö£º
ÏÈͨ¹ýnew ActiveXObject ("WbemScripting.SWbemLocator"); ·ÃÎʵ½WbemScripting¶ÔÏó¡£
ͨ¹ýlocator.ConnectServer("."); Á¬½ÓÎÒÃDZ¾µØµçÄÔ£¨.´ú±í±¾µØµçÄÔ£¬µ±È»
Ò²¿ÉÒÔ·ÃÎÊÆäËû¼ÆËã»ú£©¡£
ͨ¹ýservice.ExecQuery("SELECT * from Win32_Processor")Õâ¸öÀàËÆsqlµÄÓï¾ä£¨ÆäʵϵͳÐÅÏ¢Ò²ÊÇ´æ´¢ÔÚ¼ÆËãÖÐÒ»¸öÀàËÆÊý¾Ý¿âµÄÎļþÖУ©»ñÈ¡ÎÒÃÇÐèÒªµÄ¶ÔÏóµÄ¼Ç¼¼¯¡£
ͨ¹ýnew EnumeratorÀ´´´½¨Ò»¸ö¿Éö¾ÙµÄ¶ÔÏó£¬ÏÂÃæ¾Í¿ÉÒÔ±éÀúÈ¡ÐÅÏ¢ÁË¡£
×¢Ò⣺ÔËÐеÄÇ°ÌáÊÇÒªÐÞ¸Ää¯ÀÀÆ÷°²È«ÉèÖ㬓ÔÊÐí¶Ôδ±ê¼ÇΪ¿É°²È«Ö´ÐеÄActiveX
½Å±¾µÄÔËÐД¡£
ÕâÀïÖ÷ҪȡÁËCPU¡¢Äڴ漰ϵͳÓû§¼¸¸öÐÅÏ¢£¬´ó¼ÒÀûÓÃWMIµÄAPI»òÕß½èÖúJSEDIT»ñÈ¡
µ½¸ü¶àµÄÐÅÏ¢¡£ÏÂÃæÁгöÁ˳£ÓÃÐÅÏ¢µÄÀࣺ
Win32_Processor // CPU ´¦ÀíÆ÷
Win32_PhysicalMemory // ÎïÀíÄÚ´æ
Win32_Keyboard // ¼üÅÌ
Win32_PointingDevice // µãÊäÈëÉ豸£¬ÈçÊó±ê
Win32_DiskDrive // Ó²ÅÌÇý¶¯Æ÷
Win32_CDROMDrive // ¹âÅÌÇý¶¯Æ÷
Win32_BaseBoard // Ö÷°å
Win32_BIOS // BIOS оƬ
Win32_Paral
Ïà¹ØÎĵµ£º
scrollHeight: »ñÈ¡¶ÔÏóµÄ¹ö¶¯¸ß¶È¡£
scrollLeft:ÉèÖûò»ñȡλÓÚ¶ÔÏó×ó±ß½çºÍ´°¿ÚÖÐÄ¿Ç°¿É¼ûÄÚÈݵÄ×î×ó¶ËÖ®¼äµÄ¾àÀë
scrollTop:ÉèÖûò»ñȡλÓÚ¶ÔÏó×¶ËºÍ´°¿ÚÖпɼûÄÚÈݵÄ×¶ËÖ®¼äµÄ¾àÀë
scrollWidth:»ñÈ¡¶ÔÏóµÄ¹ö¶¯¿í¶È
offsetHeight:»ñÈ¡¶ÔÏóÏà¶ÔÓÚ°æÃæ»òÓɸ¸×ø±ê offsetParent ÊôÐÔÖ¸¶¨µÄ¸¸×ø±êµÄ¸ß¶È
offsetL ......
JavaScript--ÕýÔò±í´ïʽ
ÕýÔò±í´ïʽ(regular expression)¶ÔÏó°üº¬Ò»¸öÕýÔò±í´ïʽģʽ(pattern)¡£Ëü¾ßÓÐÓÃÕýÔò±í´ïʽģʽȥƥÅä»ò´úÌæÒ»¸ö´®(string)ÖÐÌض¨×Ö·û(»ò×Ö·û¼¯ºÏ)µÄÊôÐÔ(properties)ºÍ·½·¨(methods)¡£
ÕýÔò±í´ïʽ¹¹Ô캯Êý£º new RegExp("pattern"[,"flags"]);
²ÎÊý˵Ã÷£º
pattern -- Ò»¸öÕýÔò±í´ïʽÎı¾
flag ......
Code:
<!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>
<title>ÎÞ±êÌâÒ³</title>
<mce:script language="javascript" type="te ......
function sAlert(msg,boxtype,func,msgtitle)
sAlert('ÐÅÏ¢ÄÚÈÝ',1,'','ÐÅÏ¢±êÌâ')
@msg:ÌáʾÐÅÏ¢ÄÚÈÝ
@boxtype£º1Ϊµ¯³ö¿ò£¬2ΪȷÈÏ¿ò£¬3ΪÌáʾ¿ò
@func:µãÈ·ÈÏʱִÐеĺ¯Êý
@title:ÐÅÏ¢¿ò±êÌâÎÄ×ÖÄÚÈÝ
Ö»ÓÐmsgÊDZØÐëµÄ£¬ºóÃæµÄ²ÎÊý¿ÉÒÔÊ¡ÂÔ¡£Èç¹ûÖмäµÄ²ÎÊýΪ¿ÕÔòÔÚ¶ÔӦλÖÃÉÏ''»òÕß""±íʾ£¨¸ù¾Ýʵ¼ÊÇé¿öÑ¡Ôñµ ......
//ÅжÏÊäÈëÄÚÈÝÊÇ·ñΪ¿Õ
function IsNull(){
var str = document.getElementById('str').value.trim();
if(str.length==0){
alert('¶Ô²»Æð£¬Îı¾¿ò²»ÄÜΪ¿Õ»òÕßΪ¿Õ¸ñ!');//Ç뽫“Îı¾¿ò”¸Ä³ÉÄãÐèÒªÑéÖ¤µÄÊôÐÔÃû³Æ!
}
}
//ÅжÏÈÕÆÚÀàÐÍÊÇ·ñÎ ......