网页设计常用的一些技巧


Posted in Javascript onDecember 22, 2006

各种用途的按钮
<!--脚本说明:
把如下代码加入<body>区域中:-->
<form>
      <p>
      <input type="button" value="返回"  name="button" class="pt9">
      <input TYPE="button" NAME="view" value="查看本例的源码" view-source:" +window.location.href" class="pt9">
    </p>
</form>
<form>
<p><input TYPE="button" value="返回上一步" ></p>
</form>
<form>
<p><input TYPE="button" value="刷新按钮一" ></p>
</form>
<script language="javascript"><!--
function ReloadButton(){location.href="allbutton.htm";}
// --></script>
<form>
<p><input TYPE="button" value="刷新按钮二" > </p>
</form>
<form>
<p><input TYPE="button" value="回首页按钮" ></p>
</form>
<script language="javascript"><!--
function HomeButton(){location.href="http://vinterest.568idc.com";}/ // --></script>
<form>
<p><input TYPE="button" value="弹出警告框" ></p>
</form>
<script language="javascript"><!--
function AlertButton(){window.alert("要多多光临呀!");}
// --></script>
<form>
<p><input TYPE="button" value="状态栏信息" ></p>
</form>
<script language="javascript"><!--
function StatusButton(){window.status="要多多光临呀!";}
// --></script>
<form>
<p><input TYPE="button" value="背景色变换" ></p>
</form>
<script>function BgButton(){
if (document.bgColor=='#00ffff')
  {document.bgColor='#ffffff';}
else{document.bgColor='#00ffff';}
} </script>
<form>
<p><input TYPE="button" value="打开新窗口" ></p>
</form>
<script language="javascript"><!--
function NewWindow(){window.open("test.htm","","height=240,width=340,status=no,location=no,toolbar=no,directories=no,menubar=no");}
// --></script>

个非常漂亮的下拉列表框

<HTML>
<HEAD>
<TITLE></TITLE>
<SCRIPT LANGUAGE=javascript>
function getSelected()
{ return hDDL.innerText
} function hDDL_onmousemove()
{ window.event.cancelBubble = true
}

function DDLI_onmousemove()
{ window.event.cancelBubble = true
}

function DDLI_onmouseover(item)
{ item.style.color = DDL_HFC
item.style.backgroundColor = DDL_HBC
}

function DDLI_onmouseout(item)
{ item.style.color = DDL_FGC
item.style.backgroundColor = DDL_BGC
}

function DDLI_onclick(item)
{ hDDL.innerText = item.innerText
DDL.style.display = "none"
alert("You click " + item.innerText + "!")
}

function document_onmousemove()
{ DDL.style.display = "none"
}

function DDL_onmousemove()
{ window.event.cancelBubble = true
}

function hDDL_onclick()
{ DDL.style.posLeft = hDDL.offsetLeft
DDL.style.posTop = hDDL.offsetTop + hDDL.offsetHeight 
DDL.style.display = "block"
}

function writeDropdownList()
{

document.write("<SPAN id=hDDL")
document.write(" style="BACKGROUND-COLOR: " + DDL_BGC + ";")
document.write(" BORDER-BOTTOM: " + DDL_BC + " " + DDL_BW + " solid;")
document.write(" BORDER-LEFT: " + DDL_BC + " " + DDL_BW + " solid;")
document.write(" BORDER-RIGHT: " + DDL_BC + " " + DDL_BW + " solid;")
document.write(" BORDER-TOP: " + DDL_BC + " " + DDL_BW + " solid;")
document.write(" PADDING-LEFT: 10px; COLOR: " + DDL_FGC + ";")
document.write(" CURSOR: hand; POSITION: absolute;")
document.write(" LEFT: " + DDL_Left + "; TOP: " + DDL_Top + "; WIDTH: " + DDL_Width + """)document.write(" LANGUAGE="javascript"")
document.write(" ")
document.write(" >")

document.write(DropdownListData[0] + "</SPAN>")

document.write("<SPAN style="BACKGROUND-COLOR: " + DDL_BGC + ";")
document.write(" BACKGROUND-IMAGE: url(imageDDLpic.gif); CURSOR: hand;")document.write(" POSITION: absolute; TOP: " + (DDL_Top + DDL_BW) + ";")document.write(" LEFT: " + (DDL_Left + DDL_Width - DDL_BW - DDL_picW) + ";")document.write(" WIDTH: " + DDL_picW + ";")

document.write(" BACKGROUND-REPEAT: no-repeat"")
document.write(" LANGUAGE="javascript"")
document.write(" ")
document.write(" >")
document.write("</SPAN>")

document.write("<DIV id=DDL")
document.write(" style ="BACKGROUND-COLOR: " + DDL_BGC + ";")
document.write(" BORDER-BOTTOM: " + DDL_BC + " " + DDL_BW + " solid;")
document.write(" BORDER-LEFT: " + DDL_BC + " " + DDL_BW + " solid;")
document.write(" BORDER-RIGHT: " + DDL_BC + " " + DDL_BW + " solid;")
document.write(" BORDER-TOP: " + DDL_BC + " " + DDL_BW + " solid;")
document.write(" DISPLAY: none; POSITION: absolute;")
document.write(" LEFT: 10px; HEIGHT: 99px; TOP: 124px; WIDTH: " + DDL_Width + """)document.write(" LANGUAGE="javascript"")
document.write(" >")
var i
for(i=0; i<DropdownListData.length; i++)
{ document.write("<SPAN id=DDLI" + i)
document.write(" style="BACKGROUND-COLOR: " + DDL_BGC + "; CURSOR: hand;")document.write(" COLOR: " + DDL_FGC + "; PADDING-LEFT: 10px; WIDTH: " + (DDL_Width - 2 * DDL_BW) + """)document.write(" LANGUAGE="javascript"")
document.write("  + i + ")"")document.write("  + i + ")"")
document.write("  + i + ")"")
document.write(" >")
document.write(DropdownListData + "</SPAN><BR>")
} document.write("</DIV>")

}

document.onmousemove = document_onmousemove

var DropdownListData = new Array()

var DDL_BGC = "papayawhip"
var DDL_FGC = "green"
var DDL_HBC = "orange"
var DDL_HFC = "red"
var DDL_BC = "red"
var DDL_BW = 1
var DDL_Width = 90
var DDL_Top = 100
var DDL_Left = 80
var DDL_picW = 15

DropdownListData[0] = "Item0"
DropdownListData[1] = "Item1"
DropdownListData[2] = "Item2"
DropdownListData[3] = "Item3"
DropdownListData[4] = "Item4"

writeDropdownList()

</SCRIPT>
</HEAD>

<BODY>

<P><INPUT type="button" value="Selected" id=button1 name=button1
LANGUAGE=javascript
></P>
<P>下拉列表框演示程序:</P>
<LABEL id=l1>
</LABEL>

</BODY>
</HTML>
鼠标右键绝对禁止法

softet 

<script language="JavaScript">
<!--

if (window.Event) 
  document.captureEvents(Event.MOUSEUP); 

function nocontextmenu() 
{ event.cancelBubble = true
event.returnValue = false;

return false;
}

function norightclick(e) 
{ if (window.Event) 
{   if (e.which == 2 || e.which == 3)
  return false;
} else
  if (event.button == 2 || event.button == 3)
  {
  event.cancelBubble = true
  event.returnValue = false;
  return false;
  }

}

document.oncontextmenu = nocontextmenu;  // for IE5+
document.onmousedown = norightclick;  // for all others
//-->
</script>
Dreamweaver定制网页过渡功能:
首先用Dreamweaver打开页面,然后单击菜单中的Insert\Head\Meta(插入/文件头标签/Meta).

在对话框中的Attribute选项的下拉列表中选HTTP-equivalent选项,在Value:中键入Page-Enter,表示进入网页时有网页过渡效果。在Content:中键入Revealtrans(Duration=6,Transition=2),Duration=6表示网页过渡效果的延续时间为6秒,Transition表示过渡效果方式,值为2时表示圆形收缩。
输入完后单击确定,存盘。这样当我们点击一个超链接进入这个页面时就可以看到效果了。另外还有二十多种效供你选择,只要将Transition的值改为相应的效果的代号即可,具体效果和设置如下表所示:

效果  Content  Transitionv 
盒状收缩 RevealTrans 0  
盒状展开  RevealTrans 1 
圆形收缩  RevealTrans 2  
圆形展开 RevealTrans 3 
向上擦除 RevealTrans 4 
向下擦除 RevealTrans 5 
向左擦除 RevealTrans 6 
向右擦除 RevealTrans 7 
垂直百页窗 RevealTrans 8 
水平百页窗 RevealTrans 9 
横向棋盘式 RevealTrans 10 
纵向棋盘式 RevealTrans 11 
溶解 RevealTrans 12 
左右向中部收缩 RevealTrans 13 
中部向左右展开 RevealTrans 14 
上下向中部收缩 RevealTrans 15 
中部向上下展开 RevealTrans 16 
阶梯状向左下展开 RevealTrans 17 
阶梯状向左上展开 RevealTrans 18 
阶梯状向右下展开 RevealTrans 19 
阶梯状向右上展开 RevealTrans 20 
随机水平线 RevealTrans 21 
随机垂直线 RevealTrans 22 
随机 RevealTrans 23
加到文字中间,以显示倒计时。
<script>
var url = "html/index.html";  {'html/index.html'为转到页面}
var loctime = 9;             {9=9秒}
timedown.innerhtml = loctime;

var gourl = setInterval("downtimes()",1000);
function downtimes(){
loctime--;
timedown.innerHTML= loctime; 
if(loctime <= 0){
  clearInterval(gourl); 
  window.location = url;
}
}
</script>  

然后把
<span id="timedown"></span>
又一个一个非常漂亮的下拉列表框
<HTML>
<HEAD>
<TITLE></TITLE>
<SCRIPT LANGUAGE=javascript>
function getSelected()
{ return hDDL.innerText
} function hDDL_onmousemove()
{ window.event.cancelBubble = true
}

function DDLI_onmousemove()
{ window.event.cancelBubble = true
}

function DDLI_onmouseover(item)
{ item.style.color = DDL_HFC
item.style.backgroundColor = DDL_HBC
}

function DDLI_onmouseout(item)
{ item.style.color = DDL_FGC
item.style.backgroundColor = DDL_BGC
}

function DDLI_onclick(item)
{ hDDL.innerText = item.innerText
DDL.style.display = "none"
alert("You click " + item.innerText + "!")
}

function document_onmousemove()
{ DDL.style.display = "none"
}

function DDL_onmousemove()
{ window.event.cancelBubble = true
}

function hDDL_onclick()
{ DDL.style.posLeft = hDDL.offsetLeft
DDL.style.posTop = hDDL.offsetTop + hDDL.offsetHeight 
DDL.style.display = "block"
}

function writeDropdownList()
{

document.write("<SPAN id=hDDL")
document.write(" style="BACKGROUND-COLOR: " + DDL_BGC + ";")
document.write(" BORDER-BOTTOM: " + DDL_BC + " " + DDL_BW + " solid;")
document.write(" BORDER-LEFT: " + DDL_BC + " " + DDL_BW + " solid;")
document.write(" BORDER-RIGHT: " + DDL_BC + " " + DDL_BW + " solid;")
document.write(" BORDER-TOP: " + DDL_BC + " " + DDL_BW + " solid;")
document.write(" PADDING-LEFT: 10px; COLOR: " + DDL_FGC + ";")
document.write(" CURSOR: hand; POSITION: absolute;")
document.write(" LEFT: " + DDL_Left + "; TOP: " + DDL_Top + "; WIDTH: " + DDL_Width + """)document.write(" LANGUAGE="javascript"")
document.write(" ")
document.write(" >")

document.write(DropdownListData[0] + "</SPAN>")

document.write("<SPAN style="BACKGROUND-COLOR: " + DDL_BGC + ";")
document.write(" BACKGROUND-IMAGE: url(imageDDLpic.gif); CURSOR: hand;")document.write(" POSITION: absolute; TOP: " + (DDL_Top + DDL_BW) + ";")document.write(" LEFT: " + (DDL_Left + DDL_Width - DDL_BW - DDL_picW) + ";")document.write(" WIDTH: " + DDL_picW + ";")

document.write(" BACKGROUND-REPEAT: no-repeat"")
document.write(" LANGUAGE="javascript"")
document.write(" ")
document.write(" >")
document.write("</SPAN>")

document.write("<DIV id=DDL")
document.write(" style ="BACKGROUND-COLOR: " + DDL_BGC + ";")
document.write(" BORDER-BOTTOM: " + DDL_BC + " " + DDL_BW + " solid;")
document.write(" BORDER-LEFT: " + DDL_BC + " " + DDL_BW + " solid;")
document.write(" BORDER-RIGHT: " + DDL_BC + " " + DDL_BW + " solid;")
document.write(" BORDER-TOP: " + DDL_BC + " " + DDL_BW + " solid;")
document.write(" DISPLAY: none; POSITION: absolute;")
document.write(" LEFT: 10px; HEIGHT: 99px; TOP: 124px; WIDTH: " + DDL_Width + """)document.write(" LANGUAGE="javascript"")
document.write(" >")
var i
for(i=0; i<DropdownListData.length; i++)
{ document.write("<SPAN id=DDLI" + i)
document.write(" style="BACKGROUND-COLOR: " + DDL_BGC + "; CURSOR: hand;")document.write(" COLOR: " + DDL_FGC + "; PADDING-LEFT: 10px; WIDTH: " + (DDL_Width - 2 * DDL_BW) + """)document.write(" LANGUAGE="javascript"")
document.write("  + i + ")"")document.write("  + i + ")"")
document.write("  + i + ")"")
document.write(" >")
document.write(DropdownListData + "</SPAN><BR>")
} document.write("</DIV>")

}

document.onmousemove = document_onmousemove

var DropdownListData = new Array()

var DDL_BGC = "papayawhip"
var DDL_FGC = "green"
var DDL_HBC = "orange"
var DDL_HFC = "red"
var DDL_BC = "red"
var DDL_BW = 1
var DDL_Width = 90
var DDL_Top = 100
var DDL_Left = 80
var DDL_picW = 15

DropdownListData[0] = "Item0"
DropdownListData[1] = "Item1"
DropdownListData[2] = "Item2"
DropdownListData[3] = "Item3"
DropdownListData[4] = "Item4"

writeDropdownList()

</SCRIPT>
</HEAD>

<BODY>

<P><INPUT type="button" value="Selected" id=button1 name=button1
LANGUAGE=javascript
></P>
<P>下拉列表框演示程序:</P>
<LABEL id=l1>
</LABEL>

</BODY>
</HTML>

Javascript 相关文章推荐
javascript 3d 逐侦产品展示(核心精简)
Mar 26 Javascript
checkbox勾选判断代码分析
Jun 11 Javascript
Html5的placeholder属性(IE兼容)实现代码
Aug 30 Javascript
JavaScript基础教程之alert弹出提示框实例
Oct 16 Javascript
js鼠标点击图片切换效果代码分享
Aug 26 Javascript
如何解决easyui自定义标签 datagrid edit combobox 手动输入保存不上
Dec 26 Javascript
jQuery中通过ajax的get()函数读取页面的方法
Feb 29 Javascript
设置jQueryUI DatePicker默认语言为中文
Jun 04 Javascript
js替换字符串中所有指定的字符(实现代码)
Aug 17 Javascript
jQuery通过改变input的type属性实现密码显示隐藏切换功能
Feb 08 Javascript
详解基于 Node.js 的轻量级云函数功能实现
Jul 08 Javascript
基于JavaScript实现贪吃蛇游戏
Mar 16 Javascript
用JavaScript脚本实现Web页面信息交互
Dec 21 #Javascript
在 IE 中调用 javascript 打开 Excel 表
Dec 21 #Javascript
用js+xml自动生成表格的东西
Dec 21 #Javascript
FCK调用方法..
Dec 21 #Javascript
firefox中JS读取XML文件
Dec 21 #Javascript
URI、URL和URN之间的区别与联系
Dec 20 #Javascript
Javascript SHA-1:Secure Hash Algorithm
Dec 20 #Javascript
You might like
PHP 高手之路(二)
2006/10/09 PHP
discuz程序的PHP加密函数原理分析
2011/08/05 PHP
深入php 正则表达式的学习探讨
2013/06/06 PHP
Laravel实现用户注册和登录
2015/01/23 PHP
PHP使用数组实现矩阵数学运算的方法示例
2017/05/29 PHP
PHP实现用户异地登录提醒功能的方法【基于thinkPHP框架】
2018/03/15 PHP
PhpStorm 如何优雅的调试Hyperf的方法步骤
2019/11/24 PHP
JavaScript中的Window窗口对象
2008/01/16 Javascript
客户端限制只能上传jpg格式图片的js代码
2010/12/09 Javascript
jquery固定底网站底部菜单效果
2013/08/13 Javascript
JQuery中使用ajax传输超大数据的解决方法
2014/07/14 Javascript
jQuery实现菜单式图片滑动切换
2015/03/14 Javascript
javascript滚轮事件基础实例讲解(37)
2017/02/14 Javascript
Angular.JS中指令ng-if的注意事项小结
2017/06/21 Javascript
利用node.js制作命令行工具方法教程(一)
2017/06/22 Javascript
JS如何设置元素样式的方法示例
2017/08/28 Javascript
Vue 中的compile操作方法
2018/02/26 Javascript
babel7.x和webpack4.x配置vue项目的方法步骤
2019/05/12 Javascript
微信小程序组件传值图示过程详解
2019/07/31 Javascript
TypeScript的安装、使用、自动编译的实现
2020/04/10 Javascript
javascript如何使用函数random来实现课堂随机点名方法详解
2020/07/28 Javascript
[03:48]DOTA2完美大师赛主赛事第二日精彩集锦
2017/11/24 DOTA
pytorch + visdom CNN处理自建图片数据集的方法
2018/06/04 Python
tensorflow 加载部分变量的实例讲解
2018/07/27 Python
Python函数any()和all()的用法及区别介绍
2018/09/14 Python
python解析json串与正则匹配对比方法
2018/12/20 Python
实例讲解Python中浮点型的基本内容
2019/02/11 Python
python中selenium操作下拉滚动条的几种方法汇总
2019/07/14 Python
python tkinter控件布局项目实例
2019/11/04 Python
记一次django内存异常排查及解决方法
2020/08/07 Python
浙大网新C/C++面试解惑
2015/05/27 面试题
经典c++面试题二
2015/08/14 面试题
党员批评与自我批评
2014/02/12 职场文书
九华山导游词
2015/02/03 职场文书
法学专业求职信范文
2015/03/19 职场文书
python 中的jieba分词库
2021/11/23 Python