新手入門常用代碼集錦
更新時(shí)間:2007年01月11日 00:00:00 作者:
本貼主要是收集各種比較入門的代碼
層的隱藏與顯示
只要設(shè)置style的display屬性即可
比如<div style="display:none" id="MyDiv">隱藏的層</div>
如果要顯示它可以通過腳本來控制
window.document.getElementById("MyDiv").style.display = "";
禁止右鍵
<body oncontextmenu="return false">
屏蔽頁面中程序運(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)行一次代碼
得到本頁網(wǎng)址
var Url = window.location.href;
保存當(dāng)前頁面的內(nèi)容
document.execCommand("SaveAs","","C:\\index.htm");
層的隱藏與顯示
只要設(shè)置style的display屬性即可
比如<div style="display:none" id="MyDiv">隱藏的層</div>
如果要顯示它可以通過腳本來控制
window.document.getElementById("MyDiv").style.display = "";
禁止右鍵
<body oncontextmenu="return false">
屏蔽頁面中程序運(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)行一次代碼
得到本頁網(wǎng)址
var Url = window.location.href;
保存當(dāng)前頁面的內(nèi)容
document.execCommand("SaveAs","","C:\\index.htm");
隱去瀏覽器中當(dāng)鼠標(biāo)移到圖片上跳出的工具欄
<img galleryimg="no">
或者
<head>
<meta http-equiv="imagetoolbar" content="no">
</head>
打開,另存為,屬性,打印"等14個(gè)JS代碼
<img galleryimg="no">
或者
<head>
<meta http-equiv="imagetoolbar" content="no">
</head>
打開,另存為,屬性,打印"等14個(gè)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>
■頁面設(shè)置■
<input name=Button onClick=document.all.WebBrowser.ExecWB(8,1) type=button value=頁面設(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=查看源文件>
■語言設(shè)置■
<INPUT name=Button onclick="window.external.ShowBrowserUI(LanguageDialog, null)" type=button value=語言設(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=打開>
<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>
■頁面設(shè)置■
<input name=Button onClick=document.all.WebBrowser.ExecWB(8,1) type=button value=頁面設(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=查看源文件>
■語言設(shè)置■
<INPUT name=Button onclick="window.external.ShowBrowserUI(LanguageDialog, null)" type=button value=語言設(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ù)定義的位置無關(guān),跟函數(shù)調(diào)用方式有關(guān),需要的朋友可以參考下2023-07-07Javascript中的getUTCHours()方法使用詳解
這篇文章主要介紹了Javascript中的getUTCHours()方法使用詳解,是JS入門學(xué)習(xí)中的基礎(chǔ)知識(shí),需要的朋友可以參考下2015-06-06實(shí)例分析javascript中的call()和apply()方法
因項(xiàng)目需求去研究了下javascript中的call和apply方法,去百度看了幾篇介紹JS中call和apply的文章,總覺得不是很好懂,這里寫下我自己的理解,供網(wǎng)友們參考。2014-11-11Javascript基礎(chǔ):運(yùn)算符與流程控制詳解
這篇文章主要給大家介紹了關(guān)于Javascript中運(yùn)算符及流程控制的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(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-05