- 相關(guān)推薦
網(wǎng)頁(yè)設(shè)計(jì)常用HTML代碼大全
HTML是用來(lái)描述網(wǎng)頁(yè)的一種語(yǔ)言。下面yjbys小編為大家分享HTML代碼,希望對(duì)大家學(xué)習(xí)html代碼有幫助!
忽視右鍵
<body oncontextmenu="return false">
或
<body style="overflow-y:hidden">
1.如何幾秒后轉(zhuǎn)到別的頁(yè)面?
<META HTTP-EQUIV="Refresh" CONTENT="時(shí)間;URL=地址">
2.點(diǎn)擊關(guān)閉窗口
<a href="javascript:top.window.close();">點(diǎn)擊關(guān)閉窗口</a>!
3.請(qǐng)問(wèn)如何去掉主頁(yè)右面的滾動(dòng)條?
<body scroll="no">
<body style="overflow-y:hidden">
4.請(qǐng)問(wèn)如何做到讓一個(gè)網(wǎng)頁(yè)自動(dòng)關(guān)閉.
<html>
<head>
<OBJECT id=closes type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<param name="Command" value="Close">
</object>
</head>
<body onload="window.setTimeout(‘‘‘‘closes.Click()‘‘‘‘,10000)">
這個(gè)窗口會(huì)在10秒過(guò)后自動(dòng)關(guān)閉,而且不會(huì)出現(xiàn)提示. </body>
如何在不刷新頁(yè)面的情況下刷新css?
<style>
button{ color:#000000;}
</style>
<button onclick=document.styleSheets[0].rules[0].style.color=‘‘‘‘red‘‘‘‘>點(diǎn)擊按鈕直接修改style標(biāo)簽里button選擇符使按鈕改為紅色</button>
請(qǐng)問(wèn)如何讓網(wǎng)頁(yè)自動(dòng)刷新?
在head部記入<META HTTP-EQUIV="Refresh" content="20">其中20為20秒后自動(dòng)刷新,你可以更改為任意值。
5.如何讓頁(yè)面自動(dòng)刷新?
方法一,用refresh
HTML 代碼片段如下:
<head>
<meta http-equiv="refresh" content="5">
</head>
5表示刷新時(shí)間
[Ctrl+A 全部選擇 提示:你可先修改部分代碼,再按運(yùn)行]
方法二,使用setTimeout控制
<img src=/logo.gif>
<script>
function rl(){
document.location.reload()
}
setTimeout(rl,2000)
</script>
6.如何讓超鏈接沒(méi)有下劃線
在源代碼中的<HEAD>…</HEAD>之間輸入如下代碼:
<style type="text/css"> <!--
a { text-decoration: none}
--> </style>
7.請(qǐng)問(wèn)如何去掉IE的上下滾動(dòng)條?
<body style=‘‘‘‘overflow:scroll;overflow-y:hidden‘‘‘‘>
</body>
8.怎樣才能把RealPlayer文件在網(wǎng)頁(yè)做一個(gè)試聽(tīng)連接?
<embed height=25 src=51js.rm type=audio/x-pn-realaudio-plugin width=50 autostart="false" controls="PlayButton">
9.如何用html實(shí)現(xiàn)瀏覽器上后退按鈕的功能?
<a href="java script:history.go(-1)">點(diǎn)擊后退</a>
或者
<script> history.back() </script>
10.請(qǐng)問(wèn)怎么在網(wǎng)頁(yè)中改變鼠標(biāo)的箭頭形狀?
HTML 代碼片段如下:
<body>
<a href="#" style="cursor: auto;">auto</a><br>
<a href="#" style="cursor: crosshair ">crosshair </a><br>
<a href="#" style="cursor: default ">default </a><br>
<a href="#" style="cursor: hand ">hand </a><br>
<a href="#" style="cursor: move ">move </a><br>
<a href="#" style="cursor: e-resize ">e-resize </a><br>
<a href="#" style="cursor: ne-resize ">ne-resize </a><br>
<a href="#" style="cursor: nw-resize">nw-resize</a><br>
<a href="#" style="cursor: n-resize">n-resize</a><br>
<a href="#" style="cursor: se-resize">se-resize</a><br>
<a href="#" style="cursor: sw-resize">sw-resize</a><br>
<a href="#" style="cursor: s-resize">s-resize</a><br>
<a href="#" style="cursor: w-resize">w-resize</a><br>
<a href="#" style="cursor: text">text</a><br>
<a href="#" style="cursor: wait">wait</a><br>
<a href="#" style="cursor: help">help</a><br>
</body>
11.怎樣不使用頁(yè)面的緩存?即每一次打開(kāi)頁(yè)面時(shí)不是調(diào)用緩存中的東西
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
12.頁(yè)面打開(kāi)時(shí)自動(dòng)彈出一個(gè)窗口的代碼怎么寫?
HTML 代碼片段如下:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="<B style="color:black;background-color:#A0FFFF">javascript</B>">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" onLoad="MM_openBrWindow(‘‘‘‘http://www.35ui.cn/‘‘‘‘,‘‘‘‘,‘‘‘‘width=400,height=400‘‘‘‘)">
</body>
</html>
13.如何讓我的頁(yè)面出現(xiàn)一個(gè)會(huì)講話的小人?Merlin
HTML 代碼片段如下:
<HTML>
<HEAD>
<TITLE>默林</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
</HEAD>
<BODY>
<p><OBJECT id=sims classid=CLSID:D45FD31B-5C6E-11D1-9EC1-00C04FD7081F>
</OBJECT>
<SCRIPT>
var MerlinID;
var MerlinACS;
sims.Connected = true;
MerlinLoaded = LoadLocalAgent(MerlinID, MerlinACS);
Merlin = sims.Characters.Character(MerlinID);
Merlin.Show();
Merlin.Play("Surprised");
Merlin.Speak("大家好");
Merlin.Play("GestureLeft");
Merlin.Think("我是默林!");
Merlin.Play("Pleased");
Merlin.Think("可愛(ài)嗎?");
Merlin.Play("GestureDown");
Merlin.Speak("哈哈!");
Merlin.Hide();
function LoadLocalAgent(CharID, CharACS){
LoadReq = sims.Characters.Load(CharID, CharACS);
return(true);
}
</SCRIPT>
</p>
<p> </p>
<p>看此效果必須裝有office2000。。</p>
</BODY>
</HTML>
14.在頁(yè)面中如何加入不是滿鋪的背景圖片,拉動(dòng)頁(yè)面時(shí)背景圖不動(dòng)
HTML 代碼片段如下:
<html><head>
<STYLE>
body {background-image:url(logo.gif);
background-repeat:no-repeat; background-position:center }
</STYLE>
</head>
<body bgproperties="fixed" >
</body>
</html>
[Ctrl+A 全部選擇 提示:你可先修改部分代碼,再按運(yùn)行]
background-repeat:no-repeat; 是讓背景圖不占滿整個(gè)頁(yè)面
body bgproperties="fixed" 是拉動(dòng)scroll時(shí)背景圖不動(dòng)
15.文本輸入框什么屬性能實(shí)現(xiàn)不可輸入?
HTML 代碼片段如下:
<input type="text" name="textfield" disabled>
或者
<input type="text" name="textfield" readonly>
16.如何禁止自己的頁(yè)面在別人的框架里打開(kāi)?
把以下代碼加至你的<head>區(qū)
<script>
if (window.top!=self){
window.top.location=self.location
}
</script>
17.如何實(shí)現(xiàn)首頁(yè)全屏幕顯示?
HTML 代碼片段如下:
<html>
<body><script language="<B style="color:black;background-color:#A0FFFF">javascript</B>">
var coolw=642
var coolh=400
var coolhuang=window.open("http://www.35ui.cn","coolhuang","width="+coolw+",height="+coolh+",
fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0")
window.close()
</script></body></html>
18.如何監(jiān)聽(tīng)一個(gè)窗口被關(guān)閉了?
HTML 代碼片段如下:
<body onunload="alert(‘‘‘‘你關(guān)閉了這個(gè)窗口‘‘‘‘)">
19.如何禁止Ctrl+N?
HTML 代碼片段如下:
<body onkeydown=return(!(event.keyCode==78&&event.ctrlKey))>
如何把頁(yè)面加入用戶的收藏夾?
HTML 代碼片段如下:
<a href="<B style="color:black;background-color:#A0FFFF">javascript</B>:window.external.AddFavorite(‘‘‘‘http://www.35ui.cn‘‘‘‘,‘‘‘‘無(wú)憂腳本‘‘‘‘)">收藏?zé)o憂腳本</a>
如何在我的頁(yè)面中加入背景音樂(lè)?
IE: <bgsound src="*.mid" loop=infinite>
NS:<embed src="*.mid" autostart=true hidden=true loop=true>
*.mid你的背景音樂(lè)的midi格式文件
關(guān)于頁(yè)面轉(zhuǎn)換效果
<meta http-equiv="page-enter" content="revealTrans(Duration=4,Transition=23)">
或
<meta http-equiv="page-exit" content="revealTrans(Duration=4,Transition=23)">
說(shuō)明:Transition=23是隨機(jī)效果,另可以選0-22任一數(shù)字固定某個(gè)效果
如何設(shè)定打開(kāi)頁(yè)面的大小
HTML 代碼片段如下:
<body onload="top.resizeTo(300,200);"><!--(width,height)-->
怎樣雙擊滾屏,單擊停止?
HTML 代碼片段如下:
<html>
<head>
<title>新網(wǎng)頁(yè)1</title>
</head>
<body>
<script language"<B style="color:black;background-color:#A0FFFF">javascript</B>">
var currentpos,timer;
function initialize()
{
timer=setInterval("scrollwindow()",10);
}
function sc(){
clearInterval(timer);
}
function scrollwindow()
{
currentpos=document.body.scrollTop;
window.scroll(0,++currentpos);
if (currentpos != document.body.scrollTop)
sc();
}
document.onmousedown=sc
document.ondblclick=initialize
</script>
<p>a</p><p>a</p><p>a</p><p>aa</p><p>aa</p><p>aa</p>
<p>aa</p><p>aa</p><p>aa</p><p>aa</p><p>aa</p><p>aa</p>
<p>aa</p><p>aa</p><p>aa</p><p>aa</p><p>aa</p><p>aa</p>
<p>aa</p><p>aa</p><p>aa</p><p>aa</p><p>a</p>
</body>
</html>
如何讓body中的文字不被選中?
HTML 代碼片段如下:
<body onselectstart="return false" >aaa</body>
如何讓彈出的窗口不能關(guān)閉?
在新開(kāi)的窗口中加入如下代碼
<body onunload=open(location.href)>
</body>
如何讓瀏覽器在保存頁(yè)面時(shí)保存失敗?
HTML 代碼片段如下:
<NOSCRIPT>
<<B style="color:black;background-color:#ffff66">IFRAME</B> SRC="*.html">
</<B style="color:black;background-color:#ffff66">IFRAME</B>>
</NOSCRIPT>
表單中如何用圖片按鈕實(shí)現(xiàn) reset?
<html>
<head>
<script>
function aaa(){
document.forms[0].reset()
}
</script>
</head>
<body>
<form>
<textarea rows="2" name="S1" cols="20"></textarea>
<input type="submit" values="提交" name="B1">
<image src="logo.gif" onclick=aaa()>
</form>
</body></html>
進(jìn)入網(wǎng)頁(yè)時(shí)彈出的信息對(duì)話框
<body onLoad="window.alert(‘‘‘‘歡迎光臨本站‘‘‘‘)">
關(guān)閉窗口后彈出對(duì)話框
<body onUnload="window.alert(‘‘‘‘謝謝你的光臨!歡迎下次再來(lái)!‘‘‘‘)">
告別提示
<body onUnload= alert("再見(jiàn),感謝你的訪問(wèn)!")>
右鍵菜單的制作
<OBJECT id=menu type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<PARAM name="Command" value="Related Topics,menu">
<PARAM name="Item1" value="動(dòng)易;http://www.35ui.cn">
<PARAM name="Item2" value="搜狐;http://www.35hu.cn">
<PARAM name="Item3" value="新浪;http://www.35no.cn">
<PARAM name="Item4" value="網(wǎng)易;http://www.chinsgp.cn">
<PARAM name="Item5" value="互動(dòng)學(xué)院;http://www.35ui.cn">
</OBJECT> <script> if (document.all) document.body.onmousedown=new Function("if (event.button==2) menu.Click();") </script>
下拉菜單
<object id=HHCtrl type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"> <PARAM name="Command" value="Related Topics,Menu"> <PARAM name="Item1" value="aspease;http://www.35ui.cn"> <PARAM name="Item2" value="byhu;http://www.35ui.cn"> <PARAM name="Item3" value="lzz;http://www.35ui.cn"> </object> <a href=javascript:HHCtrl.Click() title="下拉菜單">下拉菜單</a>
【網(wǎng)頁(yè)設(shè)計(jì)常用HTML代碼】相關(guān)文章:
過(guò)濾HTML代碼08-29
php如何過(guò)濾危險(xiǎn)html代碼09-21
HTML語(yǔ)言的網(wǎng)頁(yè)教程06-14
網(wǎng)頁(yè)程序設(shè)計(jì)之實(shí)用JavaScript代碼段09-23
網(wǎng)頁(yè)程序設(shè)計(jì)之分享幾個(gè)css小眾代碼08-09
JavaScript實(shí)現(xiàn)網(wǎng)頁(yè)刷新代碼段08-07
網(wǎng)頁(yè)設(shè)計(jì)常用尺寸大小02-16
收集的常用的HTML標(biāo)簽01-22