ASP常见问题及解答(1)
1.如何 最小化、最大化、关闭窗口
答:<objectid=hh1classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<paramname="command"value="minimize"></object>
<objectid=hh2classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<paramname="command"value="maximize"></object>
<objectid=hh3classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<paramname="command"value="close"></object>
<inputtype=buttonvalue=最小化onclick=hh1.click()>
<inputtype=buttonvalue=最大化onclick=hh2.click()>
<inputtype=buttonvalue=关闭onclick=hh3.click()>
2.如何静止页面缓存
答:htm网页
<metahttp-equiv="pragma"content="no-cache">
<metahttp-equiv="cache-control"content="no-cache,must-revalidate">
<metahttp-equiv="expires"content="wed,26feb199708:21:57gmt">
或者<metahttp-equiv="expires"content="0">
asp网页
response.expires=-1
response.expiresabsolute=now()-1
response.cachecontrol="no-cache"
php网页
header("expires:mon,26jul199705:00:00gmt");
header("cache-control:no-cache,must-revalidate");
header("pragma:no-cache");
3.如何检查一段字符串是否全由数字组成
<scriptlanguage="javascript"><!--
functionchecknum(str){returnstr.match(/\d/)==null}
alert(checknum("1232142141"))
alert(checknum("123214214a1"))
//--></script>
4.如何获取机器信息
答本机ip<%=request.servervariables("remote_addr")%>
服务器名<%=request.servervariables("server_name")%>
服务器ip<%=request.servervariables("local_addr")%>
服务器端口<%=request.servervariables("server_port")%>
服务器时间<%=now%>
iis版本<%=request.servervariables"server_software")%>
脚本超时时间<%=server.scripttimeout%>
本文件路径<%=server.mappath(request.servervariables("script_name"))%>
服务器cpu数量<%=request.servervariables("number_of_processors")%>
服务器解译引擎<%=scriptengine&"/" & scriptenginemajorversion &"." & scriptengineminorversion & "." & scriptenginebuildversion%>
服务器操作系统<%=request.servervariables("os")%>
5.如何让日期相减
日期减去天数等于第二个日期
<scriptlanguage=javascript>
functioncc(dd,dadd)
{
//可以加上错误处理
vard=newdate(dd.replace("-","/"))
d.setdate(d.getdate()+dadd)
alert(d.getfullyear()+"年"+(d.getmonth()+1)+"月"+d.getdate()+"日")
}
cc("2002-2-28",2)
</script>
6.怎样通过asp的手段来检查来访者是否用了代理
<%ifrequest.servervariables("http_x_forwarded_for")<>""then
response.write"<fontcolor=#ff0000>您通过了代理服务器,"&_
"真实的ip为"&request.servervariables("http_x_forwarded_for")
endif
%>
7.获得窗口的大小
document.body.clientWidth,document.body.clientHeight
document.body.offsetWidth,document.body.offsetHeight
8.判断一个表是否存在:
if exists (select * from dbo.sysobjects where id = object_id('表名') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table 表名
GO
从publish 表中取出第 n 条到第 m 条的记录:
SELECT TOP m-n+1 *
FROM publish
WHERE (id NOT IN
(SELECT TOP n-1 id
FROM publish))
id 为publish 表的关键字
9.如何实现连续滚动
<div id="marquees"><br/><br/>
数据里面读出来的<br/>
</div>
<script language="JavaScript">
marqueesHeight=200;
stopscroll=false;
with(marquees){
style.width=0;
style.height=marqueesHeight;
style.overflowX="visible";
style.overflowY="hidden";
noWrap=true;
onmouseover=new Function("stopscroll=true");
onmouseout=new Function("stopscroll=false");
}
document.write('<div id="templayer" style="position:absolute;z-index:1;visibility:hidden"></div>');
preTop=0; currentTop=0;
function init(){
templayer.innerHTML="";
while(templayer.offsetHeight<marqueesHeight){
templayer.innerHTML+=marquees.innerHTML;
}
marquees.innerHTML=templayer.innerHTML+templayer.innerHTML;
setInterval("scrollUp()",10);
}
document.body.onload=init;
function scrollUp(){
if(stopscroll==true) return;
preTop=marquees.scrollTop;
marquees.scrollTop+=1;
if(preTop==marquees.scrollTop){
marquees.scrollTop=templayer.offsetHeight-marqueesHeight;
marquees.scrollTop+=1;
}
}
</script>
10.只针对图片:
<form name=form1 onsubmit="return mm()">
<input type=file name=meizz><br/>
<input type=submit value=submit></form>
<SCRIPT LANGUAGE="JavaScript"><!--
function mm()
{
var s = document.form1.meizz.value;
if(s=="")return false;
var img = new Image();
img.src = s;
alert("高 = "+ img.height + "\n宽 = "+ img.width);
alert("fileSize = "+ img.fileSize +" 字节");
return(img.fileSize <= 40000);
}
//--></SCRIPT>
答:<objectid=hh1classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<paramname="command"value="minimize"></object>
<objectid=hh2classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<paramname="command"value="maximize"></object>
<objectid=hh3classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<paramname="command"value="close"></object>
<inputtype=buttonvalue=最小化onclick=hh1.click()>
<inputtype=buttonvalue=最大化onclick=hh2.click()>
<inputtype=buttonvalue=关闭onclick=hh3.click()>
2.如何静止页面缓存
答:htm网页
<metahttp-equiv="pragma"content="no-cache">
<metahttp-equiv="cache-control"content="no-cache,must-revalidate">
<metahttp-equiv="expires"content="wed,26feb199708:21:57gmt">
或者<metahttp-equiv="expires"content="0">
asp网页
response.expires=-1
response.expiresabsolute=now()-1
response.cachecontrol="no-cache"
php网页
header("expires:mon,26jul199705:00:00gmt");
header("cache-control:no-cache,must-revalidate");
header("pragma:no-cache");
3.如何检查一段字符串是否全由数字组成
<scriptlanguage="javascript"><!--
functionchecknum(str){returnstr.match(/\d/)==null}
alert(checknum("1232142141"))
alert(checknum("123214214a1"))
//--></script>
4.如何获取机器信息
答本机ip<%=request.servervariables("remote_addr")%>
服务器名<%=request.servervariables("server_name")%>
服务器ip<%=request.servervariables("local_addr")%>
服务器端口<%=request.servervariables("server_port")%>
服务器时间<%=now%>
iis版本<%=request.servervariables"server_software")%>
脚本超时时间<%=server.scripttimeout%>
本文件路径<%=server.mappath(request.servervariables("script_name"))%>
服务器cpu数量<%=request.servervariables("number_of_processors")%>
服务器解译引擎<%=scriptengine&"/" & scriptenginemajorversion &"." & scriptengineminorversion & "." & scriptenginebuildversion%>
服务器操作系统<%=request.servervariables("os")%>
5.如何让日期相减
日期减去天数等于第二个日期
<scriptlanguage=javascript>
functioncc(dd,dadd)
{
//可以加上错误处理
vard=newdate(dd.replace("-","/"))
d.setdate(d.getdate()+dadd)
alert(d.getfullyear()+"年"+(d.getmonth()+1)+"月"+d.getdate()+"日")
}
cc("2002-2-28",2)
</script>
6.怎样通过asp的手段来检查来访者是否用了代理
<%ifrequest.servervariables("http_x_forwarded_for")<>""then
response.write"<fontcolor=#ff0000>您通过了代理服务器,"&_
"真实的ip为"&request.servervariables("http_x_forwarded_for")
endif
%>
7.获得窗口的大小
document.body.clientWidth,document.body.clientHeight
document.body.offsetWidth,document.body.offsetHeight
8.判断一个表是否存在:
if exists (select * from dbo.sysobjects where id = object_id('表名') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table 表名
GO
从publish 表中取出第 n 条到第 m 条的记录:
SELECT TOP m-n+1 *
FROM publish
WHERE (id NOT IN
(SELECT TOP n-1 id
FROM publish))
id 为publish 表的关键字
9.如何实现连续滚动
<div id="marquees"><br/><br/>
数据里面读出来的<br/>
</div>
<script language="JavaScript">
marqueesHeight=200;
stopscroll=false;
with(marquees){
style.width=0;
style.height=marqueesHeight;
style.overflowX="visible";
style.overflowY="hidden";
noWrap=true;
onmouseover=new Function("stopscroll=true");
onmouseout=new Function("stopscroll=false");
}
document.write('<div id="templayer" style="position:absolute;z-index:1;visibility:hidden"></div>');
preTop=0; currentTop=0;
function init(){
templayer.innerHTML="";
while(templayer.offsetHeight<marqueesHeight){
templayer.innerHTML+=marquees.innerHTML;
}
marquees.innerHTML=templayer.innerHTML+templayer.innerHTML;
setInterval("scrollUp()",10);
}
document.body.onload=init;
function scrollUp(){
if(stopscroll==true) return;
preTop=marquees.scrollTop;
marquees.scrollTop+=1;
if(preTop==marquees.scrollTop){
marquees.scrollTop=templayer.offsetHeight-marqueesHeight;
marquees.scrollTop+=1;
}
}
</script>
10.只针对图片:
<form name=form1 onsubmit="return mm()">
<input type=file name=meizz><br/>
<input type=submit value=submit></form>
<SCRIPT LANGUAGE="JavaScript"><!--
function mm()
{
var s = document.form1.meizz.value;
if(s=="")return false;
var img = new Image();
img.src = s;
alert("高 = "+ img.height + "\n宽 = "+ img.width);
alert("fileSize = "+ img.fileSize +" 字节");
return(img.fileSize <= 40000);
}
//--></SCRIPT>
- 没有相关文章
- 没有评论