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, nisusertable) = 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>
