//////////////////////// 但总感觉这样漫无目的学习,不系统而且成长太慢。 ////////////////////////我在那个时候也有这种感觉的,感觉javascript就作个表单检查,网页动态,几个属性翻过来倒过去的,没意思死了。其实不是这个样子的,所以叫脚本,MS为了扩展其体系,JS只是一个更方便,快捷,傻瓜式的东西。当你把一段脚本保存成*.js(或*.vbs)的时候,试试用鼠标双击,WINDOWS会自动的调用脚本宿主机来解释(WIN9X系列不知道有没有)。这样看来,MS对javascript的扩充,不仅仅是为了IE。试想,单纯的数据导入导出,如果没有工具吧,要自己用C写?太累了吧? 由于windows有组件,利用脚本操纵组件完成,很快的,呵呵,也许只两三句就可以了。怎么说windows呢,呵呵,看看也不是太坏哦。var tmp = new ActiveXObject("Wscript.Shell"); tmp.Run("notepad");把这两句保存成notepad.js,然后双击看看(win 2000)。
楼上说得有道理,JS和VBS都不仅仅是给网页用的。下面是个.vbs文件,你双击它看看有什么效果?Dim pubLogonURLpubLogonURL="http://expert.csdn.net/member/logon.asp"Dim pubWindow Dim pubDocumentDim pubTimeoutpubTimeout=15Set pubWindow=CreateObject("InternetExplorer.Application") pubWindow.Visible = True pubWindow.Navigate "about:blank"Set pubDocument=DocumentGetByWindows(pubWindow,pubTimeout) Set tObj=LogonGetByCreate(pubDocument) pubDocument.body.innerHTML=tObj.outerHTMLFunction DocumentGetByWindows(pWindow,pTimerout) tOnLoopTimer=Timer Do tTimeout=Abs(tOnLoopTimer-Timer) Loop Until pWindow.ReadyState=4 Or tTimeout>pTimerout Set DocumentGetByWindows=pWindow.document End FunctionFunction LogonGetByCreate(pDocument) With pDocument.body .style.backgroundcolor="rgb(0,0,0)" .style.color="rgb(255,255,255)" .style.fontfamily="宋体" .style.fontsize="9pt" End With
Set tForm=pDocument.createElement("<FORM name='alogon'>") With tForm .method="POST" .target="_blank" .name="alogon" .action=pubLogonURL End With Set tP=pDocument.createElement("P") tP.innerText="请输入ID:" tForm.insertAdjacentElement "BeforeEnd",tP Set tInputName=pDocument.createElement("<INPUT NAME='name'>") With tInputName .type="text" .name="name" .size="7" .height=22 .style.backgroundcolor="rgb(192,255,0)" .style.color="rgb(0,0,0)" .style.fontfamily="宋体" .style.fontsize="9pt" .style.borderleft="1px solid rgb(128,128,128)" .style.borderright="1px solid rgb(255,255,255)" .style.bordertop="1px solid rgb(128,128,128)" .style.borderbottom="1px solid rgb(255,255,255)" End With tForm.insertAdjacentElement "BeforeEnd",tInputName Set tP=pDocument.createElement("P") tP.innerText="请输入密码:" tForm.insertAdjacentElement "BeforeEnd",tP Set tInputPass=pDocument.createElement("<INPUT NAME='pass'>") With tInputPass .type="password" .name="pass" .size="7" .height=22 .style.backgroundcolor="rgb(192,255,0)" .style.color="rgb(0,0,0)" .style.fontfamily="宋体" .style.fontsize="9pt" .style.borderleft="1px solid rgb(128,128,128)" .style.borderright="1px solid rgb(255,255,255)" .style.bordertop="1px solid rgb(128,128,128)" .style.borderbottom="1px solid rgb(255,255,255)" End With tForm.insertAdjacentElement "BeforeEnd",tInputPass Set tInputType=pDocument.createElement("<INPUT NAME='type'>") With tInputType .type="text" .name="type" .size="7" .height=22 .value=1 .style.backgroundcolor="rgb(192,255,0)" .style.color="rgb(0,0,0)" .style.fontfamily="宋体" .style.fontsize="9pt" .style.borderleft="1px solid rgb(128,128,128)" .style.borderright="1px solid rgb(255,255,255)" .style.bordertop="1px solid rgb(128,128,128)" .style.borderbottom="1px solid rgb(255,255,255)" .style.visibility="hidden" End With tForm.insertAdjacentElement "BeforeEnd",tInputType Set tP=pDocument.createElement("P") tP.innerText="" tForm.insertAdjacentElement "BeforeEnd",tP Set tButtom=pDocument.createElement("INPUT") With tButtom .type="submit" .value="进入" .height=20 .style.backgroundcolor="rgb(100,150,200)" .style.color="rgb(255,255,255)" .style.fontfamily="宋体" .style.fontsize="9pt" .style.borderleft="2px solid rgb(255,255,255)" .style.borderright="2px solid rgb(0,50,100)" .style.bordertop="2px solid rgb(255,255,255)" .style.borderbottom="2px solid rgb(0,50,100)" End With tForm.insertAdjacentElement "BeforeEnd",tButtom Set LogonGetByCreate=tForm End Function
script怎么写得能得到很多的技巧,有问题就在这里提出来常来看看。
这样你就没问题了!!!!!!
但总感觉这样漫无目的学习,不系统而且成长太慢。
////////////////////////我在那个时候也有这种感觉的,感觉javascript就作个表单检查,网页动态,几个属性翻过来倒过去的,没意思死了。其实不是这个样子的,所以叫脚本,MS为了扩展其体系,JS只是一个更方便,快捷,傻瓜式的东西。当你把一段脚本保存成*.js(或*.vbs)的时候,试试用鼠标双击,WINDOWS会自动的调用脚本宿主机来解释(WIN9X系列不知道有没有)。这样看来,MS对javascript的扩充,不仅仅是为了IE。试想,单纯的数据导入导出,如果没有工具吧,要自己用C写?太累了吧?
由于windows有组件,利用脚本操纵组件完成,很快的,呵呵,也许只两三句就可以了。怎么说windows呢,呵呵,看看也不是太坏哦。var tmp = new ActiveXObject("Wscript.Shell");
tmp.Run("notepad");把这两句保存成notepad.js,然后双击看看(win 2000)。
Dim pubDocumentDim pubTimeoutpubTimeout=15Set pubWindow=CreateObject("InternetExplorer.Application")
pubWindow.Visible = True
pubWindow.Navigate "about:blank"Set pubDocument=DocumentGetByWindows(pubWindow,pubTimeout)
Set tObj=LogonGetByCreate(pubDocument)
pubDocument.body.innerHTML=tObj.outerHTMLFunction DocumentGetByWindows(pWindow,pTimerout)
tOnLoopTimer=Timer
Do
tTimeout=Abs(tOnLoopTimer-Timer)
Loop Until pWindow.ReadyState=4 Or tTimeout>pTimerout Set DocumentGetByWindows=pWindow.document
End FunctionFunction LogonGetByCreate(pDocument) With pDocument.body
.style.backgroundcolor="rgb(0,0,0)"
.style.color="rgb(255,255,255)"
.style.fontfamily="宋体"
.style.fontsize="9pt"
End With
Set tForm=pDocument.createElement("<FORM name='alogon'>")
With tForm
.method="POST"
.target="_blank"
.name="alogon"
.action=pubLogonURL
End With Set tP=pDocument.createElement("P")
tP.innerText="请输入ID:"
tForm.insertAdjacentElement "BeforeEnd",tP Set tInputName=pDocument.createElement("<INPUT NAME='name'>")
With tInputName
.type="text"
.name="name"
.size="7"
.height=22
.style.backgroundcolor="rgb(192,255,0)"
.style.color="rgb(0,0,0)"
.style.fontfamily="宋体"
.style.fontsize="9pt"
.style.borderleft="1px solid rgb(128,128,128)"
.style.borderright="1px solid rgb(255,255,255)"
.style.bordertop="1px solid rgb(128,128,128)"
.style.borderbottom="1px solid rgb(255,255,255)"
End With
tForm.insertAdjacentElement "BeforeEnd",tInputName Set tP=pDocument.createElement("P")
tP.innerText="请输入密码:"
tForm.insertAdjacentElement "BeforeEnd",tP Set tInputPass=pDocument.createElement("<INPUT NAME='pass'>")
With tInputPass
.type="password"
.name="pass"
.size="7"
.height=22
.style.backgroundcolor="rgb(192,255,0)"
.style.color="rgb(0,0,0)"
.style.fontfamily="宋体"
.style.fontsize="9pt"
.style.borderleft="1px solid rgb(128,128,128)"
.style.borderright="1px solid rgb(255,255,255)"
.style.bordertop="1px solid rgb(128,128,128)"
.style.borderbottom="1px solid rgb(255,255,255)"
End With
tForm.insertAdjacentElement "BeforeEnd",tInputPass Set tInputType=pDocument.createElement("<INPUT NAME='type'>")
With tInputType
.type="text"
.name="type"
.size="7"
.height=22
.value=1
.style.backgroundcolor="rgb(192,255,0)"
.style.color="rgb(0,0,0)"
.style.fontfamily="宋体"
.style.fontsize="9pt"
.style.borderleft="1px solid rgb(128,128,128)"
.style.borderright="1px solid rgb(255,255,255)"
.style.bordertop="1px solid rgb(128,128,128)"
.style.borderbottom="1px solid rgb(255,255,255)"
.style.visibility="hidden"
End With
tForm.insertAdjacentElement "BeforeEnd",tInputType Set tP=pDocument.createElement("P")
tP.innerText=""
tForm.insertAdjacentElement "BeforeEnd",tP Set tButtom=pDocument.createElement("INPUT")
With tButtom
.type="submit"
.value="进入"
.height=20
.style.backgroundcolor="rgb(100,150,200)"
.style.color="rgb(255,255,255)"
.style.fontfamily="宋体"
.style.fontsize="9pt"
.style.borderleft="2px solid rgb(255,255,255)"
.style.borderright="2px solid rgb(0,50,100)"
.style.bordertop="2px solid rgb(255,255,255)"
.style.borderbottom="2px solid rgb(0,50,100)"
End With
tForm.insertAdjacentElement "BeforeEnd",tButtom Set LogonGetByCreate=tForm
End Function
补充一点,还应学习一点面对对象的程序设计,这点对学精JS很有帮助,如果你是用JS来编写复杂的应用的话。