1.取当前网页的地址全名,以便返回用
<%
Function GetUrl()
On Error Resume Next
Dim strTemp
If LCase(Request.ServerVariables("HTTPS")) = "off" Then
strTemp = "http://";
Else
strTemp = "https://";
End If
strTemp = strTemp & Request.ServerVariables("SERVER_NAME")
If Request.ServerVariables("SERVER_PORT") <> 80 Then strTemp = strTemp & ":" & Request.ServerVariables("SERVER_PORT")
strTemp = strTemp & Request.ServerVariables("URL")
If Trim(Request.QueryString) <> "" Then strTemp = strTemp & "?" & Trim(Request.QueryString)
GetUrl = strTemp
End Function
'Response.write GetUrl()
url1=GetUrl()
url1=Server.URLEncode(url1)
%>
2.上传文件时,显示进度条程序
在需要引用进度条的也面上用
<script language="javascript" src="../ShowProcessBar.js"></script>
然后,
<input type="submit" value="开始上传" name="B1" IsShowProcessBar="True">
传参数 true
ShowProcessBar.js
—————————————————————————————————————————
AddProcessbar();
var bwidth=0;
var swidth = document.all.waiting.clientWidth;
function CheckIsProcessBar(obj)
{
if (obj.IsShowProcessBar=="True")
{
return false;
}
else
{
return true;
}
}
function CheckClick(e)
{
if (e == 1)
{
if (bwidth<swidth*0.98){
bwidth += (swidth - bwidth) * 0.025;
if (document.all)document.sbar.width = bwidth;
else document.rating.clip.width = bwidth;
setTimeout('CheckClick(1);',1000);
}
}
else
{
if(document.all)
{
if(document.all.waiting.style.visibility == 'visible')
{document.all.waiting.style.visibility = 'hidden';
bwidth = 1;}
whichIt = event.srcElement;
while (CheckIsProcessBar(whichIt))
{
whichIt = whichIt.parentElement;
if (whichIt == null)return true;
}
document.all.waiting.style.pixelTop = (document.body.offsetHeight - document.all.waiting.clientHeight) / 2 + document.body.scrollTop;
document.all.waiting.style.pixelLeft = (document.body.offsetWidth - document.all.waiting.clientWidth) / 2 + document.body.scrollLeft;
document.all.waiting.style.visibility = 'visible';
if(!bwidth)CheckClick(1);
bwidth = 1;
}
else
{
if(document.waiting.visibility == 'show')
{document.waiting.visibility = 'hide';
document.rating.visibility = 'hide';
bwidth = 1;}
if(e.target.href.toString() != '')
{
document.waiting.top = (window.innerHeight - document.waiting.clip.height) / 2 + self.pageYOffset;
document.waiting.left = (window.innerWidth - document.waiting.clip.width) / 2 + self.pageXOffset;
document.waiting.visibility = 'show';
document.rating.top = (window.innerHeight - document.waiting.clip.height) / 2 + self.pageYOffset+document.waiting.clip.height-10;
document.rating.left = (window.innerWidth - document.waiting.clip.width) / 2 + self.pageXOffset;
document.rating.visibility = 'show';
if(!bwidth)CheckClick(1);
bwidth = 1;
}
}
return true;
}
}
function AddProcessbar()
{
var Str=""
Str+= "<div id=waiting style=position:absolute;top:50px;left:100px;z-index:1;visibility:hidden >";
Str+= "<layer name=waiting visibility=visible zIndex=2 >"
Str+= "<table border=2 cellspacing=1 cellpadding=0 bordercolorlight=#FFFFFF bordercolordark=#C0C0C0 bgcolor=#E0E0E0>"
Str+= " <tr>"
Str+= " <td bgcolor=#E0E0E0 height=30px width=300px align=center>"
Str+= " <font color=black>数据正在处理中...</font>"
Str+= " </td>"
Str+= " </tr>"
Str+= " <tr>"
Str+= " <td bgcolor=#E0E0E0>"
Str+= " <img width=1 height=10 name=sbar style=background-color:#6699cc>"
Str+= " </td>"
Str+= " </tr>"
Str+= "</table> "
Str+= "</layer>"
Str+= "</div>"
document.write(Str)
if(document.all)document.onclick = CheckClick;
}
||||||3.控制滚动:
=============
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body style="margin:0px">
<table width="110" border="0" align="center" cellpadding="2" cellspacing="0" height="300px">
<tr>
<td id="i">
<marquee id="mar" direction="up" behavior="slide" height="100px" style="background-Color:#00ff00">
<div style="background-Color:#ff0000" id="div">
<p><a href="#">分类一</a></p>
<p>分类二</p>
<p>分类三</p>
<p>分类四</p>
<p>分类五</p>
<p>分类六</p>
</div>
</marquee>
<div id="div"></div>
</td>
</tr>
<tr>
<td>
<input type="button" name="btnUp" value="向上" onMouseOver="UpScroll();" onMouseOut="StopScroll();">
<input name="btnDown" type="button" value="向下" onMouseOver="DownScroll();" onMouseOut="StopScroll();">
</td>
</tr>
</table>
<script language="JavaScript">
var timer;
var mar = document.all.mar;
var div = document.all.div;
var h1 = div.offsetHeight;
var h2 = mar.height;
//向上移动
function UpMarquee(){
if(mar.scrollTop>=h1)
StopScroll();
else
mar.scrollTop+=1;
}
function DownMarquee(){
if(mar.scrollTop<=h2)
StopScroll();
else
mar.scrollTop-=1;
//alert(mar.scrollTop);
}
//循环调用向下移动函数
function UpScroll(){
//alert(mar.scrollTop);
//StopScroll();
timer = setInterval('UpMarquee()',50);//循环调用
}
//循环调用向上移动函数
function DownScroll(){
//StopScroll();
timer = setInterval('DownMarquee()',50);//循环调用
}
//清除循环调用
function StopScroll(){
clearInterval(timer);
}
</script>
</body>
</html>
检查时间:
================
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<script language="JavaScript">
function isValid(vlu)
{
var tmp1 = "";
var i = 0;
var bool = true;
vlu += ":";
i = vlu.indexOf(":");
tmp = vlu.substr(0,i);
vlu = vlu.substr(i+1,vlu.length);
bool = isErr(tmp) & isErr1(tmp) & isErr2(tmp);
i = vlu.indexOf(":");
tmp = vlu.substr(0,i);
vlu = vlu.substr(i+1,vlu.length);
bool &= isErr(tmp) & isErr1(tmp) & isErr3(tmp);
i = vlu.indexOf(":");
tmp = vlu.substr(0,i);
vlu = vlu.substr(i+1,vlu.length);
bool &= isErr(tmp) & isErr1(tmp) & isErr3(tmp);
if(bool == true)
alert("ok.");
else
alert("The time is incorrect.");
}
function isErr(vlu)
{
var bool = vlu.indexOf("-") >= 0 ? false : true;
bool &= vlu.indexOf(".") >= 0 ? false : true;
return bool;
}
function isErr1(vlu)
{
return isNaN(parseInt(vlu)) ? false : true;
}
function isErr2(vlu)
{
return parseInt(vlu) > 23 ? false : true;
}
function isErr3(vlu)
{
return parseInt(vlu) > 59 ? false : true;
}
//isValid("25:59:00");
</script>
</head>
<body>
<input name="txtTime" type="text" id="txtTime" value="09:05:59">
<input type="button" name="Submit" value="°´Å¥" onClick="isValid(document.all.txtTime.value);">
</body>
</html>
||||||4.调用Css做颜色变换:
======================
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>ÎÞ±êÌâÎĵµ</title>
<style type="text/css">
<!--
.red {
background-color: #FF0000;
}
.blue {
background-color: #0000FF;
}
.yellow {
background-color: #FFFF00;
}
.green {
background-color: #00FF00;
}
.black {
background-color: #000000;
}
.white {
background-color: #FFFFFF;
}
.cyan {
background-color: #00FFFF;
}
.purple {
background-color: #FF00FF;
}
-->
</style>
<script language="javascript">
var timer;
var arrColor = new Array("red","green","yellow","blue","black","white","cyan","purple");
var index1 = 0;
var index2 = 7;
function ChangeColor1()
{
for(var i=0; i<8; i++)
{
if(index1 == 8) index1 = 0;
document.all('t'+(i+1)).className = arrColor[index1];
document.all('b'+(i+1)).innerText = document.all('t'+(i+1)).className;
document.all('b'+(i+1)).style.color = arrColor[index1++];
}
if(index1 == 8) index1 = 0;
index1++;
}
function ChangeColor2()
{
for(var i=8; i>0; i--)
{
if(index2 == 0) index2 = 8;
document.all('c'+i).className = arrColor[--index2];
document.all('f'+i).innerText = document.all('c'+i).className;
document.all('f'+i).style.color = arrColor[index2];
}
if(index2 == 0) index2 = 8;
--index2;
}
</script>
</head>
<body onLoad="setInterval('ChangeColor1()',500);setInterval('ChangeColor2()',500);">
<table width="720" border="1" align="center" cellpadding="0" cellspacing="0">
<colgroup>
<col width="12.5%">
<col width="12.5%">
<col width="12.5%">
<col width="12.5%">
<col width="12.5%">
<col width="12.5%">
<col width="12.5%">
<col width="12.5%">
</colgroup>
<tr>
<td id="t1" class="red" height="30"> </td>
<td id="t2" class="green"> </td>
<td id="t3