当前位置: 首页 > 图文教程 > 网页制作 > HTML/XHTML教程 > 网页制作有用的代码

HTML/XHTML教程
一些不太常用的XHTML标签用法以及实例
网页中图片的设置涉及的三个问题
商业HTML邮件的制作建议
HTML Marquee 字符片段滚动
DOCTYPE 文档类型声明(网页爱好者必看)
纯HTML标签你熟悉多少?
HTML元素的ID和Name属性的区别
HTML meta的大作用
HTML标签tbody的用法与说明
HTML 特殊字符转换表
HTML基础 HTML的组成结构
HTML基础之HTML内容细则
Shtml 精简教程
浅谈html table 标签
html Frame、Iframe、Frameset 的区别
HTML 网页页面切换的各种变换效果
HTML的10个表格相关标记
让IE8启动IE7兼容模式的代码
HTML 结构化实现方法
xhtml的块级标记小结

HTML/XHTML教程 中的 网页制作有用的代码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-11   浏览: 106 ::
收藏到网摘: n/a


请问如何去掉主页右面的滚动条?
<body scroll="no">
<body style="overflow-y:hidden">
********************************
怎样不使用页面的缓存?即每一次打开页面时不是调用缓存中的东西
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
********************************
请问如何忽视右键?
<body oncontextmenu="return false">
********************************
怎样在同一页面内控制不同链接的CSS属性?
a:active{}
a:link{}
a:visited{}
a.1:active{}
a.1:link{}
a.1:visited{}
在DW的CSS中定义一个新的标示,按照HTML的语法,超级连接得是
A.YOURS:LINK A.YOURS:HOVER
YOURS可以改作你自己的字
然后在选中某个连接后,在CSS面版中点中YOURS即可。
按需要,你可以定义N个标示,N种鼠标OVER的效果
********************************
电子邮件处理提交表单
<form name="form1" method="post" action="mailto:[email protected]" enctype="text/plain">
<input type=submit>
</form>
********************************
有没有可能用层来遮住FLASH?
1.在flash的parameters里加入 <param name="wmode" value="transparent">
2.<body onblur=self.focus()>
********************************
如何根据屏幕分辨率调用相对应的页面?
onclick=alert("你的显示分辩率为:" screen.width "×" screen.height)
先做好几个页面,比如一个htm1.htm是800*600,一个是htm2.htm是1024*768的
然后在你的入口页面 index.htm 中判断:
<html>
<head>
<script language=javascript>
<!--
function mHref() {
if (screen.width == 1024) location.href = "htm2.htm";
else if (screen.width == 800) location.href = "htm1.htm";
else return(false);
}
//-->
</script>
</head>
<body onload="mHref();">
</body>
</html>
********************************
如何弹出只有状态栏的窗口?
<html>
<head>
<title>open() close()</title>
<script language="javascript" type="text/javascript">
<!--
function openWin()
{
var newWin=open("","","menubar=1,height=200");
newWin.document.write("<form>");
newWin.document.write("单击以下按钮关闭窗口:<p>");
newWin.document.write("<input type=button value='关闭' onclick=window.close()>");
newWin.document.write("</form>");
}
</script></head>
<body>
<div align=center>
<h2>单击以下按钮显示新窗口...</h2>
<form name=form1>
<input type=button value="新窗口1[只显示地址栏]" onclick=window.open('','new1','location=1')>
<input type=button value="新窗口2[只显示状态栏]" onclick=window.open('','','status=1')>
<input type=button value="新窗口3[只显示工具栏]" onclick=window.open('','new2','toolbar=1,height=200,width=450')>
<input type=button value="新窗口4[只显示菜单栏]" onclick=openWin()>
<input type=button value="新窗口5[一个不少]" onclick=window.open('','new5')>
<input type=button value="新窗口6[光棍但可调大小]" onclick=window.open('http://www.ruanchen.com/','new6','resizable=1')>
</form>
</div>
</body>
</html>
                                                   

********************************
如何让超链接没有下划线
在源代码中的<HEAD>…</HEAD>之间输入如下代码:
<style type="text/css"> <!--
a { text-decoration: none}
--> </style>
********************************
请问如何做到让一个网页自动关闭.
<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)">
这个窗口会在10秒过后自动关闭,而且不会出现提示. </body>
********************************
如何几秒后转到别的页面?
代码片段如下:
<META HTTP-EQUIV="Refresh" CONTENT="10;URL=http://www.ruanchen.com">
十秒中后跳到ruanchen.com的首页
********************************
怎样才能把RealPlayer文件在网页做一个试听连接?
<embed height=25 src=51js.rm type=audio/x-pn-realaudio-plugin width=50 autostart="false" controls="PlayButton">
********************************
请问如何去掉IE的上下滚动条?
<body style='overflow:scroll;overflow-y:hidden'>
</body>
********************************
解释一下event.X和event.clientX有什么区别?
event.clientX返回事件发生时,mouse相对于客户窗口的X坐标
event.X也一样
但是如果设置事件对象的定位属性值为relative
event.clientX不变
而event.X返回事件对象的相对于本体的坐标
event对象详解 ICOOE 2000.3.31 http://www.ruanchen.com/'javascript'>
function aa(){
y=window.showModalDialog("http://www.ruanchen.com","","Height: 300; Width: 275; help: no");
}
</script>
                                                   

********************************************
target="_blank"规定链接在新窗口中打开,那 target="_parent"、 target="_self" 、target="_top"的作用又是什么?
target="_parent"、上一层框架
target="_self" 、自身窗口、框架
target="_top" 最顶层框架。
更细点的解释,从网上找来的:
_blank
開啟一個新的視窗,而且是沒有命名的視窗。
_self
強迫連結的結果顯示在同一個子畫面,而忽略 BASE 的設定。
_parent
在該子畫面的「父畫面」(也就是上一層的 FRAMESET)中顯示連結的結果。
_top
從視窗的最上頭開始顯示畫面;換句話說就是先清除整個視窗後再載入連結。
********************************************
如何使网友收藏本网时,收藏夹显示的不是微软的那个一成不变的标志,而是本人选择的ICON?
<LINK href="fav.ico" rel="shortcut icon">
加入HADE標簽中,圖片放入根目錄下,須是.ico格式.
有的空間不支援直接放在根目錄
必須加上
<LINK href="路徑/圖檔.ico" rel="shortcut icon">
********************************************
如何监听一个窗口被关闭了?
<body onunload="alert('你关闭了这个窗口')">
********************************************
什么是innerHTML、outerHTML………还有innerText?
<div id=test><table><tr><td>文本<a>链接</a>另一段文本</td></tr></table></div>
<input type=button onclick=alert(test.innerText) value="show innerText"><br>
<input type=button onclick=alert(test.innerHTML) value="show innerHTML"><br>
<input type=button onclick=alert(test.outerHTML) value="show outerHTML"><br>
********************************************
window方法列表!
发现经常有人问一些有关窗口操作的问题,
所以花了些时间整理出这篇文章,
希望以后不会再有人问这方面的问题。
ie里window的method列表
alert(sMsg)
//弹出一个确认消息框
attachEvent(sEvent,pFunction)
//绑定一个函数到某个事件,事件触发时随机执行其中一个被绑定的函数
blur()
//令窗口丧失焦点
clearInterval(iIntervalID)
//清除指定定时器的关联函数
clearTimeout(iTimeoutID)
//清除指定延时器的关联函数
close()
//关闭窗口,如果窗口不是用脚本打开的,会弹出确认对话框。
confirm([sMessage])
//弹出“确定/取消”对话框
createPopup([vArgs])
//创建一个隐藏的弹出式窗口,vArgs是未来考虑提供的参数,返回窗口句柄
detachEvent(sEvent,pFunction)
//取消一个事件的某个绑定函数
execScript(sExpression, sLanguage)
//用指定的语言执行代码
focus()
//激活窗口
moveBy(iX,iY)
//用相对方式移动窗口
moveTo(iLeft,iTop)
//用绝对方式移动窗口
navigate(sURL)
//转到指定的连接
open( [sURL] [, sName] [, sFeatures] [, bReplace])
//打开新窗口,并返回窗口句柄
//sName=(*_blank:打开一个新的未命名窗口;_parent:在父窗口中打开;_search:同时打开搜索窗口;_self:替换本窗口; _top:在顶级窗口里打开;*)
//sFeatures=(*channelmode = { yes | no | 1 | 0 };directories = { yes | no | 1 | 0 };fullscreen = { yes | no | 1 | 0 };height = number;left = number;location = { yes | no | 1 | 0 };menubar = { yes | no | 1 | 0 };resizable = { yes | no | 1 | 0 };scrollbars = { yes | no | 1 | 0 };status = { yes | no | 1 | 0 };titlebar = { yes | no | 1 | 0 };toolbar = { yes | no | 1 | 0 };top = number;width = number;*)
print()
//打印当前窗口文档内容
prompt( [sMessage] [, sDefaultValue])
//弹出输入对话框
resizeBy(iX, iY)
//以相对方式改变窗口大小
resizeTo(iWidth, iHeight)
//以绝对方式改变窗口大小
scroll(iX,iY)
滚动窗口,与scrollTo一样的效果,出于兼容性的考虑保留下来的方法
scrollBy(iX, iY)
//用相对方式滚动窗口
scrollTo(iX, iY)
//用绝对方式滚动窗口
setActive()
//激活目标而不将视线转向目标
setInterval(vCode, iMilliSeconds [, sLanguage])
//定时执行一段代码
setTimeout(vCode, iMilliSeconds, sLanguage)
//延时执行一段代码
showHelp(sURL [, vContextID])
//打开一个帮助文件,sURL为帮助文档地址,vContextID为帮助索引号
showModalDialog(sURL [, vArguments] [, sFeatures])
showModalDialog(sURL [, vArguments] [, sFeatures])
//打开一个模式对话框
//vArguments=需要向新开模式对话框传递的参数
//sFeatures=(*dialogHeight:sHeight;dialogLeft:sXPos;dialogTop:sYPos;dialogWidth:sWidth;center:{ yes | no | 1 | 0 | on | off };dialogHide:{ yes | no | 1 | 0 | on | off };edge:{ sunken | raised };help:{ yes | no | 1 | 0 | on | off };resizable:{ yes | no | 1 | 0 | on | off };scroll:{ yes | no | 1 | 0 | on | off };status:{ yes | no | 1 | 0 | on | off };unadorned:{ yes | no | 1 | 0 | on | off };*)
showModelessDialog(sURL [, vArguments] [, sFeatures])
//打开一个非模式对话框
//vArgument=需要向新开模式对话框传递的参数
//sFeatures=(*dialogHeight:sHeight;dialogLeft:sXPos;dialogTop:sYPos;dialogWidth:sWidth;center:{ yes | no | 1 | 0 | on | off };dialogHide:{ yes | no | 1 | 0 | on | off };edge:{ sunken | raised };help:{ yes | no | 1 | 0 | on | off };resizable:{ yes | no | 1 | 0 | on | off };scroll:{ yes | no | 1 | 0 | on | off };status:{ yes | no | 1 | 0 | on | off };unadorned:{ yes | no | 1 | 0 | on | off };*)
********************************************
execCommand的完全参考(中文版)
document.execCommand(sCommand[,交互方式, 动态参数])
2D-Position;document.execCommand("2D-Position","false","true");使绝对定位的对象可直接拖动;ie5.5
AbsolutePosition;document.execCommand("AbsolutePosition","false","true");使对象定位变成绝对定位;ie5.5
BackColor;document.execCommand("BackColor","false",sColor);设置背景颜色;ie4.0
BlockDirLTR;none;使块级元素排版方式为从左到右?;不支持
BlockDirRTL;none;使块级元素排版方式为从右到左?;不支持 Bold;document.execCommand("Bold","false",null);使选中区域的文字加粗;ie4.0
BrowseMode;none;设置浏览器模式?;不支持 Copy;
document.execCommand("Copy","false",null);复制选中的文字到剪贴板;ie4.0 CreateBookmark;document.execCommand("CreateBookmark","false",sAnchorName);设置指定锚点为书签;ie4.0
CreateLink;document.execCommand("CreateLink","false",sLinkURL);将选中文本变成超连接,若第二个参数为true,会出现参数设置对话框;ie4.0
Cut;document.execCommand("Cut","false",null);剪贴选中的文字到剪贴板;ie4.0
Delete;document.execCommand("Delete","false",null);删除选中的文字;ie4.0
DirLTR;none;排版方式为从左到右?;不支持 DirRTL;none;排版方式为从右到左?;不支持
EditMode;none;设置编辑模式?;不支持
FontName;document.execCommand("FontName","false",sFontName);改变选中区域的字体;ie4.0
FontSize;document.execCommand("FontSize","false",sSize|iSize);改变选中区域的字体大小;ie4.0
ForeColor;document.execCommand("ForeColor","false",sColor);设置前景颜色;ie4.0
FormatBlock;document.execCommand("FormatBlock","false",sTagName);设置当前块的标签名;ie4.0
********************************************
如何把页面加入用户的收藏夹?
<a href="javascript:window.external.AddFavorite('http://www.ruanchen.com','软晨学习网脚本')">收藏软晨学习网脚本</a>
********************************************
如何让浏览器在保存页面时保存失败?
<NOSCRIPT>
<IFRAME SRC="*.html">
</IFRAME>
</NOSCRIPT>
********************************************
一个页面内所有复选框的全选功能如何实现?
<input type=checkbox><input type=checkbox>
<input type=checkbox><input type=checkbox>
<button onclick=SelectAll()>SelectAll</button>
<script>
function SelectAll()
{
var cInput=document.all.tags('INPUT');
for(var i in cInput)
if(cInput[i].type=='checkbox')cInput[i].checked=true;
}
</script>
********************************************
如何在不刷新页面的情况下刷新css?
<style>
button{ color:#000000;}
</style>
<button onclick=document.styleSheets[0].rules[0].style.color='red'>点击按钮直接修改style标签里button选择符使按钮改为红色</button>