网页设计常见代码,HTML5代码,前端代码常见问题

1、超链接去掉下划线

<HEAD>
<style type="text/css"> <!--
a { text-decoration: none}
--> 
</style>
</HEAD>

2、去掉网页右边滚动条

<body scroll="no">
<body style="overflow-y:hidden">

去掉网页的上下滚动条

<body style='overflow:scroll;overflow-y:hidden'>
</body>

3、如何忽视右键

<body oncontextmenu="return false">

4、常用小标签

target="_blank"在新窗口中打开链接页面
target="_parent"上一层框架
target="_self"自身窗口、框架
target="_top"最顶层框架
5、电子邮件处理提交表单

<form name="form1" method="post" action="mailto:[email protected]" enctype="text/plain">
<input type=submit>
</form>

6、怎样不使用页面的缓存,即每一次打开页面时不是调用缓存中的东西

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">

7、根据屏幕分辩率调用相应的页面

οnclick=alert(“你的显示分辩率为:”+screen.width+“×”+screen.height)

预先设计好几个页面,如htm1.htm是800600、htm2.htm是1024768等,然后在入口页面中判断:

<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>

8、如何弹出只有状态栏的窗口

<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('地址','new6','resizable=1')>
</form>
</div>
</body>
</html>

9、如何让一个网页在10秒后自动关闭

<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)">
</body>     //**窗口会在10秒过后自动关闭,而且不会出现提示** 

加上下面的代码,就自定义时间跳转页面
<META HTTP-EQUIV="Refresh" CONTENT="10;URL=http://www.baidu.com">
10、把RealPlayer文件在网页做一个试听连接

<embed height=25 src=“文件地址” type=audio/x-pn-realaudio-plugin width=50 autostart="false" controls="PlayButton">

11、让窗口固定在最上面,不随页面滚动而变化位置?

<a onclick=aa()>点这里</a>
<script language='javascript'>
function aa(){
y=window.showModalDialog("http://www.51js.com","","Height: 300; Width: 275; help: no");
}
</script>

12、在收藏页面时,显示自定义的ICON图标?

<LINK href="fav.ico" rel="shortcut icon">

加入HADE标签内,图片放入根目录下,必须是.ico格式。若不支持直接放在根目录下,须加上
<LINK href="路径/****.ico" rel="shortcut icon">

13、如何把页面加入用户的收藏夹

<a href="javascript:window.external.AddFavorite('http://www.baidu.com','百度首页')">百度首页</a>

14、如何让浏览器在保存页面时保存失败

<NOSCRIPT>
<IFRAME SRC="*.html">
</IFRAME>
</NOSCRIPT>

15、实现复选框的全选功能

<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>

16、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>

17、在不刷新页面的情况下刷新css

<style>
button{ color:#000000;}
</style>
<button onclick=document.styleSheets[0].rules[0].style.color='red'>点击按钮直接修改style,标签里button选择符使按钮改为红色</button>

17、怎么在同一页面控制不同链接的CSS属性?

a:active{}
a:link{}
a:visited{}
a.1:active{}
a.1:link{}
a.1:visited{}

按照HTML的语法,超级连接得是A.YOURS:LINK A.YOURS:HOVER,其中YOURS可以自定义,然后在选中某个连接后,在CSS面版中点中YOURS即可。
你可以定义n个标识,n种鼠标OVER的效果。
19、Windows方法列表
clearInterval(iIntervalID)//清除指定定时器的关联函数
clearTimeout(iTimeoutID)//清除指定延时器的关联函数
attachEvent(sEvent,pFunction)//将函数与某个事件绑定,当事件触发时随机执行被绑定的函数
detachEvent(sEvent,pFunction)//取消一个事件的某个绑定函数

blur()//使窗口丧失焦点
focus()//激活窗口
setActive()//激活目标而不将视线转向目标

alert(sMsg)/ /弹出一个确认消息框
confirm([sMessage])//弹出“确定/取消”对话框
createPopup([vArgs])//创建隐藏的弹出窗口,vArgs是参数,返回窗口句柄

open([sURL] [, sName] [, sFeatures] [, bReplace])//打开新窗口,并返回窗口句柄
moveBy(iX,iY)//用相对方式移动窗口
moveTo(iLeft,iTop)//用绝对方式移动窗口

prompt( [sMessage] [, sDefaultValue])//弹出输入对话框
resizeBy(iX, iY)//以相对方式改变窗口大小
resizeTo(iWidth, iHeight)//以绝对方式改变窗口大小

scroll(iX,iY)//滚动窗口,与scrollTo一样的效果,兼容性
scrollBy(iX, iY)//用相对方式滚动窗口
scrollTo(iX, iY)//用绝对方式滚动窗口

setInterval(vCode, iMilliSeconds [, sLanguage])//定时执行一段代码
setTimeout(vCode, iMilliSeconds, sLanguage)//延时执行一段代码
execScript(sExpression, sLanguage)//用指定的语言执行代码
navigate(sURL)//转到指定的链接

showHelp(sURL [, vContextID])//打开一个帮助文件,sURL为帮助文档地址,vContextID为帮助索引号
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 };)

猜你喜欢

转载自blog.csdn.net/weixin_44435602/article/details/99837893