欢迎光临
我们一直在努力

ASP常见问题及解答(4)-ASP教程,ASP技巧

建站超值云服务器,限时71元/月

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="°&acute;&aring;&yen;" onclick="isvalid(document.all.txttime.value);">

</body>

</html>

4.调用css做颜色变换:

======================

<html>

<head>

<meta http-equiv="content-type" content="text/html; charset=gb2312">

<title>&icirc;&thorn;±ê&igrave;&acirc;&icirc;&auml;&micro;&micro;</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">&nbsp;</td>

<td id="t2" class="green">&nbsp;</td>

<td id="t3" class="yellow">&nbsp;</td>

<td id="t4" class="blue">&nbsp;</td>

<td id="t5" class="black">&nbsp;</td>

<td id="t6" class="white">&nbsp;</td>

<td id="t7" class="cyan">&nbsp;</td>

<td id="t8" class="purple">&nbsp;</td>

</tr>

<tr style="font-size:10px" align="center">

<td id="b1" height="30">&nbsp;</td>

<td id="b2">&nbsp;</td>

<td id="b3">&nbsp;</td>

<td id="b4">&nbsp;</td>

<td id="b5">&nbsp;</td>

<td id="b6">&nbsp;</td>

<td id="b7">&nbsp;</td>

<td id="b8">&nbsp;</td>

</tr>

<tr>

<td colspan="8" height="100">&nbsp;</td>

</tr>

<tr>

<td id="c1" class="red" height="30">&nbsp;</td>

<td id="c2" class="green">&nbsp;</td>

<td id="c3" class="yellow">&nbsp;</td>

<td id="c4" class="blue">&nbsp;</td>

<td id="c5" class="black">&nbsp;</td>

<td id="c6" class="white">&nbsp;</td>

<td id="c7" class="cyan">&nbsp;</td>

<td id="c8" class="purple">&nbsp;</td>

</tr>

<tr style="font-size:10px" align="center">

<td id="f1" height="30">&nbsp;</td>

<td id="f2">&nbsp;</td>

<td id="f3">&nbsp;</td>

<td id="f4">&nbsp;</td>

<td id="f5">&nbsp;</td>

<td id="f6">&nbsp;</td>

<td id="f7">&nbsp;</td>

<td id="f8">&nbsp;</td>

</tr>

</table>

</body>

</html>

5.asp中怎么运行一个服务器端程序呢

set wshshell = server.createobject("wscript.shell")

retcode = wshshell.run("d:\xxx.exe", 1, true)

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » ASP常见问题及解答(4)-ASP教程,ASP技巧
分享到: 更多 (0)

相关推荐

  • 暂无文章