1-忽视右键
<body oncontextmenu="return false">
或
<body style="overflow-y:hidden">
2-加入背景音乐
IE:<bgsound src="*.mid" loop=infinite>
NS:<embed src="*.mid" autostart=true hidden=true loop=true>
</embed>
*.mid你的背景音乐的midi格式文件
3-简单的window.open方法
<a href="#"
onclick="javascript:window.open(文件路径/文件名,newwindow,
toolbar=no,scrollbars=yes,resizable=no,top=0,left=0,
width=400,height=300);">文字或图片</a>
参数解释:
<SCRIPT LANGUAGE="javascript"> js脚本开始;
window.open 弹出新窗口的命令;
文件路径/文件名 弹出窗口的文件名;
newwindow 弹出窗口的名字(不是文件名),非必须,可用空代替;
width=400 窗口宽度;
height=300 窗口高度;
top=0 窗口距离屏幕上方的象素值;
left=0 窗口距离屏幕左侧的象素值;
toolbar=no 是否显示工具栏,yes为显示;
menubar,scrollbars 表示菜单栏和滚动栏。
resizable=no 是否允许改变窗口大小,yes为允许;
location=no 是否显示地址栏,yes为允许;
status=no 是否显示状态栏内的信息(通常是文件已经打开),yes为允许;
</SCRIPT> js脚本结束
4-简单的页面加密
<script LANGUAGE="javascript">
<!--
function loopy(){
var sWord ="";
while(sWord!="login"){sWord=prompt("请输入你的登陆密码");}
alert("登陆成功!");
}
loopy()
//-->
</script>
5-拉动页面时背景图不动
<style>
body{background-image:url(logo.gif);
background-repeat:no-repeat;background-position:center}
</style>
6-让浏览器在保存页面时保存失败
<NOSCRIPT><iframe src="*.html"></iframe></NOSCRIPT>
7-随机替换图片
<script>
document.write(<img src="img/+parseInt(Math.random()*(5))
+.gif"height="40" width="50">)
</script>
图片文件名为0.gif 1.gif 2.gif 3.gif 4.gif
8-窗口定时关闭
先将如下代码网页文件的区:
<script language="javascript">
function closeit() { setTimeout("self.close()",10000) //毫秒 }
</script>
然后再在<body>标内加入如:<body onload="closeit()">
9-网页自动关闭
<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>
</html>
10-网页自动刷新
在head部记入
<META HTTP-EQUIV="Refresh" content="20">
其中20为20秒后自动刷新,你可以更改为任意值。
11-网页自动转页
<META HTTP-EQUIV="Refresh" CONTENT="时间(秒);URL=地址">
12-保持layer在最前面,而不被Iframe、Object所覆盖
在Layer中再插Iframe 或 Object 设z-Index值
<div z-Index:2><object xxx></object> # 前面
<div z-Index:1><object xxx></object> # 后面
<div id="Layer2" style="position:absolute; top:40;400px;
height:95px;z-index:2"> height=100% width=100%>
<iframe width=0 height=0></iframe>
</div>
<div id="Layer1" style="position:absolute; top:50;200px;
height:115px;z-index:1">
<iframe height=100% width=100%></iframe>
</div>
13-返回上一页
<a href=javascript:history.back(1)>『返回上一页』</a>
14-关闭窗口
<a href=javascript:self.close()>『关闭窗口』</a>
15-关于iframe的透明背景
<IFRAME ID="iFrame1" SRC="iframe.htm"
allowTransparency="true"
style="background-color: green"></IFRAME>
16-页面载入信息(下角的状态栏显示)
<script language=VBScript>
<!-- Begin
Dim Bar, Line, SP
Bar = 0
Line = "|"
SP = 100
Function Window_onLoad()
Bar = 95
SP = 10
End Function
Function Count()
If Bar < 100 Then
Bar = Bar + 1
Window.Status = "页面迅速载入,请稍后---" & Bar & "%" & " " & String(Bar, Line)
setTimeout "Count()", SP
Else
Window.Status = "欢迎光临XX"
Document.Body.Style.Display = ""
End If
End Function
Call Count()
// End -->
</script>
17-时间日历
<SCRIPT LANGUAGE="JavaScript">
var months = new Array("一", "二", "三","四", "五", "六", "七", "八", "九","十", "十一", "十二");
var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31,30, 31, 30, 31);
var days = new Array("日","一", "二", "三","四", "五", "六");
var classTemp;
var calendarHover="calendarHover";
var today=new getToday();
var year=today.year;
var month=today.month;
var newCal;
//得到某月天数
function getDays(month, year)
{ if (1 == month)
return ((0 == year % 4) && (0 != (year % 100))) ||(0 == year % 400) ? 29 : 28;
else
return daysInMonth[month];
}
//得到当天时间信息
function getToday()
{ this.now = new Date();
this.year = this.now.getFullYear();
this.month = this.now.getMonth();
this.day = this.now.getDate();
}
//生成日历
function Calendar()
{ newCal = new Date(year,month,1); //当前月的第一天
today = new getToday();
var day = -1; //用来判断日历中是否为当天
var startDay = newCal.getDay(); //当月开始时间
var endDay=getDays(newCal.getMonth(), newCal.getFullYear());//当月结束时间
var daily = 0; //用来生成日历中的天数值
if ((today.year == newCal.getFullYear()) &&(today.month == newCal.getMonth()))
day = today.day;
var caltable = document.all.caltable.tBodies.calendar; //得到日历表格的集合
var intDaysInMonth =getDays(newCal.getMonth(), newCal.getFullYear()); //得到当月天数
//生成日历
for (var intWeek = 0; intWeek < caltable.rows.length;intWeek++)
for (var intDay = 0;intDay < caltable.rows[intWeek].cells.length;intDay++)
{
var cell = caltable.rows[intWeek].cells[intDay]; //得到单元袼
//生成字符串用于判断当天是否有日志
var montemp=(newCal.getMonth()+1)<10?("0"+(newCal.getMonth()+1)):(newCal.getMonth()+1);
if ((intDay == startDay) && (0 == daily)){ daily = 1;}
var daytemp=daily<10?("0"+daily):(daily);
var d="<"+newCal.getFullYear()+"-"+montemp+"-"+daytemp+">";
//选择样式
if(day==daily)
cell.className="calendarNow";
else if(diarydays.indexOf(d)!=-1)
cell.className="calendarLink";
else if(intDay==6)
cell.className = "calendarDaySat";
else if (intDay==0)
cell.className ="calendarDaySun";
else
cell.className="calendarTd";
//生成值
if ((daily > 0) && (daily <= intDaysInMonth))
{ cell.innerText = daily;
daily++;
}
else
cell.innerText = "";
}
document.all.year.value=year;
document.all.month.value=month+1;
}
function subMonth()
{
if ((month-1)<0)
{
month=11;
year=year-1;
}
else
{
month=month-1;
}
Calendar();
}
function addMonth()
{
if((month+1)>11)
{
month=0;
year=year+1;
}
else
{
month=month+1;
}
Calendar();
}
//得到响应事件
function getDiary()
{
var mon=(newCal.getMonth()+1)<10?("0"+(newCal.getMonth()+1)):(newCal.getMonth()+1);
var day=event.srcElement.innerText<10?("0"+event.srcElement.innerText):(event.srcElement.innerText);
var d="<"+newCal.getFullYear()+"-"+mon+"-"+day+">";
if ("TD" == event.srcElement.tagName)
if (("" != event.srcElement.innerText)&&(diarydays.indexOf(d)!=-1))
{
diary.location="/KanJing/archive/"+newCal.getFullYear()+"/"+mon+"/"+day+".aspx";
window.location.href = diary.location;
}
}
function setDate()
{
if (document.all.month.value<1||document.all.month.value>12)
{
alert("月的有效范围在1-12之间!");
return;
}
year=Math.ceil(document.all.year.value);
month=Math.ceil(document.all.month.value-1);
Calendar();
}
</SCRIPT>
<table width="180" border="0" align="center" cellpadding="0" cellspacing="1" class="calendarBigBorder" id="caltable">
<thead>
<tr align="center" valign="middle">
<td colspan="7" class="calendarMonthTitle style3">SoShow现在为你报时:<div id="jnkc"></div><script>setInterval("jnkc.innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt (new Date().getDay());",1000);</script></td>
</tr>
<tr align="center" valign="middle">
<td colspan="7" bgcolor="#FFFFFF" class="calendarMonthTitle">
<input name="year" type="text" class="calendarYInput" size="6" maxlength="4" onkeydown="if (event.keyCode==13){setDate()}" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')" onpaste="this.value=this.value.replace(/[^0-9]/g,'')">年
<input name="month" type="text" class="calendarMInput" size="2" maxlength="1" onkeydown="if (event.keyCode==13){setDate()}" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')" onpaste="this.value=this.value.replace(/[^0-9]/g,'')">月 [<a onClick="addMonth()" href="javascript:;">下月</a>] [<a onClick="subMonth()" href="javascript:;">上月</a>]</td>
</tr>
<tr align="center" valign="middle">
<SCRIPT LANGUAGE="JavaScript">
document.write("<TD class=calendarDaySun id=diary>" + days[0] + "</TD>");
for (var intLoop = 1; intLoop < days.length-1;
intLoop++)
document.write("<TD class=calendarTd id=diary>" + days[intLoop] + "</TD>");
document.write("<TD class=calendarDaySat id=diary>" + days[intLoop] + "</TD>");
</SCRIPT>
18--鼠标
<SCRIPT LANGUAGE=javascript>
function click() {
alert('禁止你的左键复制!') }
function click1() {
if (event.button==2) {alert('禁止右键点击~!') }}
function CtrlKeyDown(){
if (event.ctrlKey) {alert('不当的拷贝将损害您的系统!') }}
document.onkeydown=CtrlKeyDown;
document.onselectstart=click;
document.onmousedown=click1;
</SCRIPT>
19---页面切换效果
<meta HTTP-EQUIV="Page-Enter" CONTENT="revealtrans(duration=6.0, transition=23)">
<meta HTTP-EQUIV="Page-Exit" CONTENT="revealtrans(duration=6.0, transition=23)">
<meta http-equiv="Page-Enter" content="RevealTrans(duration=5,Transitionv=11)">
duration=时间
Transitionv=方式
Page-Enter
说明:duration为页面切换的时间长度,3.000表示3秒钟,一般可以直接输入3便可;transition为切换效果,从1-23共22种不同的切换效果,其中23为随机效果。
效果 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