新手入門(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中的this關(guān)鍵字指向
這篇文章主要介紹了深入了解JavaScript中的this關(guān)鍵字指向,在大多情況下,this出現(xiàn)在函數(shù)中,this指向什么,跟函數(shù)定義的位置無(wú)關(guān),跟函數(shù)調(diào)用方式有關(guān),需要的朋友可以參考下2023-07-07Es6 寫(xiě)的文件import 起來(lái)解決方案詳解
這篇文章主要介紹了如何讓es6 寫(xiě)的文件import 起來(lái)詳解的相關(guān)資料,需要的朋友可以參考下2016-12-12Javascript中的getUTCHours()方法使用詳解
這篇文章主要介紹了Javascript中的getUTCHours()方法使用詳解,是JS入門(mén)學(xué)習(xí)中的基礎(chǔ)知識(shí),需要的朋友可以參考下2015-06-06實(shí)例分析javascript中的call()和apply()方法
因項(xiàng)目需求去研究了下javascript中的call和apply方法,去百度看了幾篇介紹JS中call和apply的文章,總覺(jué)得不是很好懂,這里寫(xiě)下我自己的理解,供網(wǎng)友們參考。2014-11-11Javascript基礎(chǔ):運(yùn)算符與流程控制詳解
這篇文章主要給大家介紹了關(guān)于Javascript中運(yùn)算符及流程控制的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-10-10從零學(xué)JSON之JSON數(shù)據(jù)結(jié)構(gòu)
這篇文章主要介紹了JSON數(shù)據(jù)結(jié)構(gòu)的相關(guān)知識(shí),需要的朋友可以參考下2014-05-05onmouseover和onmouseout的一些問(wèn)題思考
這兩個(gè)事件的觸發(fā)表現(xiàn)真的就是你想要的嗎?在IE下確實(shí)有你需要的兩個(gè)這樣事件:onmouseenter 和 onmouseleave。但很不幸FF等其他瀏覽器并不支持2013-08-08