新手入門常用代碼集錦
更新時間:2007年01月11日 00:00:00 作者:
本貼主要是收集各種比較入門的代碼
層的隱藏與顯示
只要設置style的display屬性即可
比如<div style="display:none" id="MyDiv">隱藏的層</div>
如果要顯示它可以通過腳本來控制
window.document.getElementById("MyDiv").style.display = "";
禁止右鍵
<body oncontextmenu="return false">
屏蔽頁面中程序運行出錯信息
window.onerror = function()
{
return true;
}
得到當前顯示器的分辨率
window.srceen.width 得到屏幕的寬度
window.srceen.height 得到屏幕的高度
如果當前分辨率為800*600,window.srceen.width是800,window.srceen.height是600
定時運行特定代碼
setTimeout(Code,Timeout);
setInterval(Code,Timeout);
Code是一段字符串,里邊是js代碼,Timeout是時間間隔,單位是微秒
setTimeout是從現(xiàn)在算起多少微秒后運行該代碼(只運行一次)
setInterval是每隔多少微秒運行一次代碼
得到本頁網(wǎng)址
var Url = window.location.href;
保存當前頁面的內(nèi)容
document.execCommand("SaveAs","","C:\\index.htm");
層的隱藏與顯示
只要設置style的display屬性即可
比如<div style="display:none" id="MyDiv">隱藏的層</div>
如果要顯示它可以通過腳本來控制
window.document.getElementById("MyDiv").style.display = "";
禁止右鍵
<body oncontextmenu="return false">
屏蔽頁面中程序運行出錯信息
window.onerror = function()
{
return true;
}
得到當前顯示器的分辨率
window.srceen.width 得到屏幕的寬度
window.srceen.height 得到屏幕的高度
如果當前分辨率為800*600,window.srceen.width是800,window.srceen.height是600
定時運行特定代碼
setTimeout(Code,Timeout);
setInterval(Code,Timeout);
Code是一段字符串,里邊是js代碼,Timeout是時間間隔,單位是微秒
setTimeout是從現(xiàn)在算起多少微秒后運行該代碼(只運行一次)
setInterval是每隔多少微秒運行一次代碼
得到本頁網(wǎng)址
var Url = window.location.href;
保存當前頁面的內(nèi)容
document.execCommand("SaveAs","","C:\\index.htm");
隱去瀏覽器中當鼠標移到圖片上跳出的工具欄
<img galleryimg="no">
或者
<head>
<meta http-equiv="imagetoolbar" content="no">
</head>
打開,另存為,屬性,打印"等14個JS代碼
<img galleryimg="no">
或者
<head>
<meta http-equiv="imagetoolbar" content="no">
</head>
打開,另存為,屬性,打印"等14個JS代碼
■打開■
<input name=Button onClick=document.all.WebBrowser.ExecWB(1,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(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>
■頁面設置■
<input name=Button onClick=document.all.WebBrowser.ExecWB(8,1) type=button value=頁面設置><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()">
■導入收藏■
<input type="button" name="Button" value="導入收藏夾" onClick=window.external.ImportExportFavorites(true,);>
■導出收藏■
<input type="button" name="Button3" value="導出收藏夾" 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=查看源文件>
■語言設置■
<INPUT name=Button onclick="window.external.ShowBrowserUI(LanguageDialog, null)" type=button value=語言設置>
■前進■
<INPUT name=Submit onclick=history.go(1) type=submit value=前進>
■后退■
<INPUT name=Submit2 onclick=history.go(-1) type=submit value=后退>
<input name=Button onClick=document.all.WebBrowser.ExecWB(1,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(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>
■頁面設置■
<input name=Button onClick=document.all.WebBrowser.ExecWB(8,1) type=button value=頁面設置><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()">
■導入收藏■
<input type="button" name="Button" value="導入收藏夾" onClick=window.external.ImportExportFavorites(true,);>
■導出收藏■
<input type="button" name="Button3" value="導出收藏夾" 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=查看源文件>
■語言設置■
<INPUT name=Button onclick="window.external.ShowBrowserUI(LanguageDialog, null)" type=button value=語言設置>
■前進■
<INPUT name=Submit onclick=history.go(1) type=submit value=前進>
■后退■
<INPUT name=Submit2 onclick=history.go(-1) type=submit value=后退>
相關文章
詳解JavaScript中雙等號引起的隱性類型轉(zhuǎn)換
JavaScript中由==判斷所引起的轉(zhuǎn)換會引發(fā)解釋器的一些列執(zhí)行步驟,接下來我們就來詳解JavaScript中雙等號引起的隱性類型轉(zhuǎn)換,需要的朋友可以參考下2016-05-05
JavaScript中的Number數(shù)字類型學習筆記
對數(shù)字類型支持得不夠強大是很多人吐槽JavaScript的原因,anyway...這里整理了JavaScript中的Number數(shù)字類型學習筆記,適合入門及基礎知識復習,需要的朋友可以參考下2016-05-05
window.location.href的用法(動態(tài)輸出跳轉(zhuǎn))
無論在靜態(tài)頁面還是動態(tài)輸出頁面中window.location.href都是不錯的用了跳轉(zhuǎn)的實現(xiàn)方案2014-08-08

