新手入門(mén)常用代碼集錦
更新時(shí)間:2007年01月11日 00:00:00 作者:
本貼主要是收集各種比較入門(mén)的代碼
層的隱藏與顯示
只要設(shè)置style的display屬性即可
比如<div style="display:none" id="MyDiv">隱藏的層</div>
如果要顯示它可以通過(guò)腳本來(lái)控制
window.document.getElementById("MyDiv").style.display = "";
禁止右鍵
<body oncontextmenu="return false">
屏蔽頁(yè)面中程序運(yùn)行出錯(cuò)信息
window.onerror = function()
{
return true;
}
得到當(dāng)前顯示器的分辨率
window.srceen.width 得到屏幕的寬度
window.srceen.height 得到屏幕的高度
如果當(dāng)前分辨率為800*600,window.srceen.width是800,window.srceen.height是600
定時(shí)運(yùn)行特定代碼
setTimeout(Code,Timeout);
setInterval(Code,Timeout);
Code是一段字符串,里邊是js代碼,Timeout是時(shí)間間隔,單位是微秒
setTimeout是從現(xiàn)在算起多少微秒后運(yùn)行該代碼(只運(yùn)行一次)
setInterval是每隔多少微秒運(yùn)行一次代碼
得到本頁(yè)網(wǎng)址
var Url = window.location.href;
保存當(dāng)前頁(yè)面的內(nèi)容
document.execCommand("SaveAs","","C:\\index.htm");
層的隱藏與顯示
只要設(shè)置style的display屬性即可
比如<div style="display:none" id="MyDiv">隱藏的層</div>
如果要顯示它可以通過(guò)腳本來(lái)控制
window.document.getElementById("MyDiv").style.display = "";
禁止右鍵
<body oncontextmenu="return false">
屏蔽頁(yè)面中程序運(yùn)行出錯(cuò)信息
window.onerror = function()
{
return true;
}
得到當(dāng)前顯示器的分辨率
window.srceen.width 得到屏幕的寬度
window.srceen.height 得到屏幕的高度
如果當(dāng)前分辨率為800*600,window.srceen.width是800,window.srceen.height是600
定時(shí)運(yùn)行特定代碼
setTimeout(Code,Timeout);
setInterval(Code,Timeout);
Code是一段字符串,里邊是js代碼,Timeout是時(shí)間間隔,單位是微秒
setTimeout是從現(xiàn)在算起多少微秒后運(yùn)行該代碼(只運(yùn)行一次)
setInterval是每隔多少微秒運(yùn)行一次代碼
得到本頁(yè)網(wǎng)址
var Url = window.location.href;
保存當(dāng)前頁(yè)面的內(nèi)容
document.execCommand("SaveAs","","C:\\index.htm");
隱去瀏覽器中當(dāng)鼠標(biāo)移到圖片上跳出的工具欄
<img galleryimg="no">
或者
<head>
<meta http-equiv="imagetoolbar" content="no">
</head>
打開(kāi),另存為,屬性,打印"等14個(gè)JS代碼
<img galleryimg="no">
或者
<head>
<meta http-equiv="imagetoolbar" content="no">
</head>
打開(kāi),另存為,屬性,打印"等14個(gè)JS代碼
■打開(kāi)■
<input name=Button onClick=document.all.WebBrowser.ExecWB(1,1) type=button value=打開(kāi)>
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■另存為■
<input name=Button onClick=document.all.WebBrowser.ExecWB(4,1) type=button value=另存為><OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■屬性■
<input name=Button onClick=document.all.WebBrowser.ExecWB(10,1) type=button value=屬性><OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■打印■
<input name=Button onClick=document.all.WebBrowser.ExecWB(6,1) type=button value=打印><OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■頁(yè)面設(shè)置■
<input name=Button onClick=document.all.WebBrowser.ExecWB(8,1) type=button value=頁(yè)面設(shè)置><OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■刷新■
<input type=button value=刷新 name=refresh onclick="window.location.reload()">
■導(dǎo)入收藏■
<input type="button" name="Button" value="導(dǎo)入收藏夾" onClick=window.external.ImportExportFavorites(true,);>
■導(dǎo)出收藏■
<input type="button" name="Button3" value="導(dǎo)出收藏夾" onClick=window.external.ImportExportFavorites(false,);>
■加入收藏■
<INPUT name=Button2 onclick="window.external.AddFavorite(location.href, document.title)" type=button value=加入收藏夾>
■整理收藏夾■
<INPUT name=Submit2 onclick="window.external.ShowBrowserUI(OrganizeFavorites, null)" type=button value=整理收藏夾>
■查看原文件■
<INPUT name=Button onclick=window.location = "view-source:" + window.location.href type=button value=查看源文件>
■語(yǔ)言設(shè)置■
<INPUT name=Button onclick="window.external.ShowBrowserUI(LanguageDialog, null)" type=button value=語(yǔ)言設(shè)置>
■前進(jìn)■
<INPUT name=Submit onclick=history.go(1) type=submit value=前進(jìn)>
■后退■
<INPUT name=Submit2 onclick=history.go(-1) type=submit value=后退>
<input name=Button onClick=document.all.WebBrowser.ExecWB(1,1) type=button value=打開(kāi)>
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■另存為■
<input name=Button onClick=document.all.WebBrowser.ExecWB(4,1) type=button value=另存為><OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■屬性■
<input name=Button onClick=document.all.WebBrowser.ExecWB(10,1) type=button value=屬性><OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■打印■
<input name=Button onClick=document.all.WebBrowser.ExecWB(6,1) type=button value=打印><OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■頁(yè)面設(shè)置■
<input name=Button onClick=document.all.WebBrowser.ExecWB(8,1) type=button value=頁(yè)面設(shè)置><OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■刷新■
<input type=button value=刷新 name=refresh onclick="window.location.reload()">
■導(dǎo)入收藏■
<input type="button" name="Button" value="導(dǎo)入收藏夾" onClick=window.external.ImportExportFavorites(true,);>
■導(dǎo)出收藏■
<input type="button" name="Button3" value="導(dǎo)出收藏夾" onClick=window.external.ImportExportFavorites(false,);>
■加入收藏■
<INPUT name=Button2 onclick="window.external.AddFavorite(location.href, document.title)" type=button value=加入收藏夾>
■整理收藏夾■
<INPUT name=Submit2 onclick="window.external.ShowBrowserUI(OrganizeFavorites, null)" type=button value=整理收藏夾>
■查看原文件■
<INPUT name=Button onclick=window.location = "view-source:" + window.location.href type=button value=查看源文件>
■語(yǔ)言設(shè)置■
<INPUT name=Button onclick="window.external.ShowBrowserUI(LanguageDialog, null)" type=button value=語(yǔ)言設(shè)置>
■前進(jìn)■
<INPUT name=Submit onclick=history.go(1) type=submit value=前進(jìn)>
■后退■
<INPUT name=Submit2 onclick=history.go(-1) type=submit value=后退>
相關(guān)文章
詳解JavaScript中雙等號(hào)引起的隱性類型轉(zhuǎn)換
JavaScript中由==判斷所引起的轉(zhuǎn)換會(huì)引發(fā)解釋器的一些列執(zhí)行步驟,接下來(lái)我們就來(lái)詳解JavaScript中雙等號(hào)引起的隱性類型轉(zhuǎn)換,需要的朋友可以參考下2016-05-05
JavaScript中的Number數(shù)字類型學(xué)習(xí)筆記
對(duì)數(shù)字類型支持得不夠強(qiáng)大是很多人吐槽JavaScript的原因,anyway...這里整理了JavaScript中的Number數(shù)字類型學(xué)習(xí)筆記,適合入門(mén)及基礎(chǔ)知識(shí)復(fù)習(xí),需要的朋友可以參考下2016-05-05
window.location.href的用法(動(dòng)態(tài)輸出跳轉(zhuǎn))
無(wú)論在靜態(tài)頁(yè)面還是動(dòng)態(tài)輸出頁(yè)面中window.location.href都是不錯(cuò)的用了跳轉(zhuǎn)的實(shí)現(xiàn)方案2014-08-08
JavaScript高級(jí)程序設(shè)計(jì) 學(xué)習(xí)筆記 js高級(jí)技巧
JavaScript高級(jí)程序設(shè)計(jì) 學(xué)習(xí)筆記 js高級(jí)技巧,學(xué)習(xí)js的朋友可以參考下。2011-09-09
JavaScript高級(jí)程序設(shè)計(jì)(第3版)學(xué)習(xí)筆記 概述
在JavaScript面世之初,沒(méi)有人會(huì)想到它會(huì)被應(yīng)用的如此廣泛,也遠(yuǎn)比一般人想象中的要復(fù)雜強(qiáng)大的多,在我自己學(xué)習(xí)的過(guò)程中,曾經(jīng)有過(guò)多次震撼2012-10-10
如何學(xué)習(xí)Javascript入門(mén)指導(dǎo)
首先要說(shuō)明的是,咱現(xiàn)在不是高手,最多還是一個(gè)半桶水,算是入了JS的門(mén)2013-11-11

