随笔-179  评论-666  文章-29  trackbacks-0

名称: 使网页自动定时刷新

实例: 本页自动定时刷新

代码: 将以下代码加入html<head></head>之间<br>

 

<:  meta http-equiv="refresh" content="10; url=你想访问的网址"> <br>

 

说明: 其中10代表当前页完全下载完成10秒后自动链接到指定的url,把url去掉就表示每隔10秒自动刷新一次主页。  <br>

 

 

''验证合法email地址: <br>

 

function isvalidemail(email)

dim names, name, i, c

isvalidemail = true

names = split(email, "@")

if ubound(names) <> 1 then

  isvalidemail = false

  exit function

end if

for each name in names

  if len(name) <= 0 then

    isvalidemail = false

    exit function

  end if

  for i = 1 to len(name)

    c = lcase(mid(name, i, 1))

    if instr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not isnumeric(c) then

      isvalidemail = false

      exit function

    end if

  next

  if left(name, 1) = "." or right(name, 1) = "." then

     isvalidemail = false

     exit function

  end if

next

if instr(names(1), ".") <= 0 then

  isvalidemail = false

  exit function

end if

i = len(names(1)) - instrrev(names(1), ".")

if i <> 2 and i <> 3 then

  isvalidemail = false

  exit function

end if

if instr(email, "..") > 0 then

  isvalidemail = false

end if

end function

 

%>

 

 

 

16.使用fso修改文件特定内容的函数

function fsochange(filename,target,string)

dim objfso,objcountfile,filetempdata

set objfso = server.createobject("scripting.filesystemobject")

set objcountfile = objfso.opentextfile(server.mappath(filename),1,true)

filetempdata = objcountfile.readall

objcountfile.close

filetempdata=replace(filetempdata,target,string)

set objcountfile=objfso.createtextfile(server.mappath(filename),true)

objcountfile.write filetempdata

objcountfile.close

set objcountfile=nothing

set objfso = nothing

end function

 

 

17.使用fso读取文件内容的函数

function fsofileread(filename)

dim objfso,objcountfile,filetempdata

set objfso = server.createobject("scripting.filesystemobject")

set objcountfile = objfso.opentextfile(server.mappath(filename),1,true)

fsofileread = objcountfile.readall

objcountfile.close

set objcountfile=nothing

set objfso = nothing

end function

 

 

18.使用fso读取文件某一行的函数

function fsolinedit(filename,linenum)

if linenum < 1 then exit function

dim fso,f,temparray,tempcnt

set fso = server.createobject("scripting.filesystemobject")

if not fso.fileexists(server.mappath(filename)) then exit function

set f = fso.opentextfile(server.mappath(filename),1)

if not f.atendofstream then

tempcnt = f.readall

f.close

set f = nothing

temparray = split(tempcnt,chr(13)&chr(10))

if linenum>ubound(temparray)+1 then

 exit function

else

 fsolinedit = temparray(linenum-1)

end if

end if

end function

 

 

 

19.使用fso写文件某一行的函数

function fsolinewrite(filename,linenum,linecontent)

if linenum < 1 then exit function

dim fso,f,temparray,tempcnt

set fso = server.createobject("scripting.filesystemobject")

if not fso.fileexists(server.mappath(filename)) then exit function

set f = fso.opentextfile(server.mappath(filename),1)

if not f.atendofstream then

tempcnt = f.readall

f.close

temparray = split(tempcnt,chr(13)&chr(10))

if linenum>ubound(temparray)+1 then

 exit function

else

 temparray(linenum-1) = linecontent

end if

tempcnt = join(temparray,chr(13)&chr(10))

set f = fso.createtextfile(server.mappath(filename),true)

f.write tempcnt

end if

f.close

set f = nothing

end function

 

 

 

20.使用fso添加文件新行的函数

function fsoappline(filename,linecontent)

dim fso,f

set fso = server.createobject("scripting.filesystemobject")

if not fso.fileexists(server.mappath(filename)) then exit function

set f = fso.opentextfile(server.mappath(filename),8,1)

f.write chr(13)&chr(10)&linecontent

f.close

set f = nothing

end function

 

 

 

21.读文件最后一行的函数

function fsolastline(filename)

dim fso,f,temparray,tempcnt

set fso = server.createobject("scripting.filesystemobject")

if not fso.fileexists(server.mappath(filename)) then exit function

set f = fso.opentextfile(server.mappath(filename),1)

if not f.atendofstream then

tempcnt = f.readall

f.close

set f = nothing

temparray = split(tempcnt,chr(13)&chr(10))

 fsolastline = temparray(ubound(temparray))

end if

end function

 

 

[推荐]利用fso取得bmpjpgpnggif文件信息(大小,宽、高等)

<%

   ':::      bmp,  gif,  jpg  and  png                                                                          :::

 

   ':::    this  function  gets  a  specified  number  of  bytes  from  any        :::

   ':::    file,  starting  at  the  offset  (base  1)                                            :::

   ':::                                                                                                                          :::

   ':::    passed:                                                                                                        :::

   ':::              flnm                =>  filespec  of  file  to  read                              :::

   ':::              offset            =>  offset  at  which  to  start  reading              :::

   ':::              bytes              =>  how  many  bytes  to  read                                  :::

   ':::                                                                                                                          :::

   ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

 

 

   function  getbytes(flnm,  offset,  bytes)

         dim  objfso

         dim  objftemp

         dim  objtextstream

         dim  lngsize

         on  error  resume  next

         set  objfso  =  createobject("scripting.filesystemobject")

         

         '  first,  we  get  the  filesize

         set  objftemp  =  objfso.getfile(flnm)

         lngsize  =  objftemp.size

         set  objftemp  =  nothing

         fsoforreading  =  1

         set  objtextstream  =  objfso.opentextfile(flnm,  fsoforreading)

         if  offset  >  0  then

               strbuff  =  objtextstream.read(offset  -  1)

         end  if

         if  bytes  =  -1  then                  '  get  all!

               getbytes  =  objtextstream.read(lngsize)    'readall

         else

               getbytes  =  objtextstream.read(bytes)

         end  if

         objtextstream.close

         set  objtextstream  =  nothing

         set  objfso  =  nothing

   end  function

 

   ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

   ':::                                                                                                                          :::

   ':::    functions  to  convert  two  bytes  to  a  numeric  value  (long)      :::

   ':::    (both  little-endian  and  big-endian)                                                :::

   ':::                                                                                                                          :::

   ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

 

 

   function  lngconvert(strtemp)

         lngconvert  =  clng(asc(left(strtemp,  1))  +  ((asc(right(strtemp,  1))  *  256)))

   end  function

   function  lngconvert2(strtemp)

         lngconvert2  =  clng(asc(right(strtemp,  1))  +  ((asc(left(strtemp,  1))  *  256)))

   end  function

 

 

   

   ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

   ':::                                                                                                                          :::

   ':::    this  function  does  most  of  the  real  work.  it  will  attempt    :::

   ':::    to  read  any  file,  regardless  of  the  extension,  and  will        :::

   ':::    identify  if  it  is  a  graphical  image.                                              :::

   ':::                                                                                                                          :::

   ':::    passed:                                                                                                        :::

   ':::              flnm                =>  filespec  of  file  to  read                              :::

   ':::              width              =>  width  of  image                                                  :::

   ':::              height            =>  height  of  image                                                :::

   ':::              depth              =>  color  depth  (in  number  of  colors)            :::

   ':::              strimagetype=>  type  of  image  (e.g.  gif,  bmp,  etc.)        :::

   ':::                                                                                                                          :::

   ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

 

 

 

   function  gfxspex(flnm,  width,  height,  depth,  strimagetype)

         dim  strpng  

         dim  strgif

         dim  strbmp

         dim  strtype

         strtype  =  ""

         strimagetype  =  "(unknown)"

         gfxspex  =  false

         strpng  =  chr(137)  &  chr(80)  &  chr(78)

         strgif  =  "gif"

         strbmp  =  chr(66)  &  chr(77)

         strtype  =  getbytes(flnm,  0,  3)

         if  strtype  =  strgif  then                                                      '  is  gif

               strimagetype  =  "gif"

               width  =  lngconvert(getbytes(flnm,  7,  2))

               height  =  lngconvert(getbytes(flnm,  9,  2))

               depth  =  2  ^  ((asc(getbytes(flnm,  11,  1))  and  7)  +  1)

               gfxspex  =  true

         elseif  left(strtype,  2)  =  strbmp  then                            '  is  bmp

               strimagetype  =  "bmp"

               width  =  lngconvert(getbytes(flnm,  19,  2))

               height  =  lngconvert(getbytes(flnm,  23,  2))

               depth  =  2  ^  (asc(getbytes(flnm,  29,  1)))

               gfxspex  =  true

         elseif  strtype  =  strpng  then                                              '  is  png

               strimagetype  =  "png"

               width  =  lngconvert2(getbytes(flnm,  19,  2))

               height  =  lngconvert2(getbytes(flnm,  23,  2))

               depth  =  getbytes(flnm,  25,  2)

               select  case  asc(right(depth,1))

                     case  0

                           depth  =  2  ^  (asc(left(depth,  1)))

                           gfxspex  =  true

                     case  2

                           depth  =  2  ^  (asc(left(depth,  1))  *  3)

                           gfxspex  =  true

                     case  3

                           depth  =  2  ^  (asc(left(depth,  1)))    '8

                           gfxspex  =  true

                     case  4

                           depth  =  2  ^  (asc(left(depth,  1))  *  2)

                           gfxspex  =  true

                     case  6

                           depth  =  2  ^  (asc(left(depth,  1))  *  4)

                           gfxspex  =  true

                     case  else

                           depth  =  -1

               end  select

         else

               strbuff  =  getbytes(flnm,  0,  -1)                  '  get  all  bytes  from  file

               lngsize  =  len(strbuff)

               flgfound  =  0

               strtarget  =  chr(255)  &  chr(216)  &  chr(255)

               flgfound  =  instr(strbuff,  strtarget)

               if  flgfound  =  0  then

                     exit  function

               end  if

               strimagetype  =  "jpg"

               lngpos  =  flgfound  +  2

               exitloop  =  false

               do  while  exitloop  =  false  and  lngpos  <  lngsize

                     do  while  asc(mid(strbuff,  lngpos,  1))  =  255  and  lngpos  <  lngsize

                           lngpos  =  lngpos  +  1

                     loop

                     if  asc(mid(strbuff,  lngpos,  1))  <  192  or  asc(mid(strbuff,  lngpos,  1))  >  195  then

                           lngmarkersize  =  lngconvert2(mid(strbuff,  lngpos  +  1,  2))

                           lngpos  =  lngpos  +  lngmarkersize    +  1

                     else

                           exitloop  =  true

                     end  if

             loop

             '

             if  exitloop  =  false  then

                   width  =  -1

                   height  =  -1

                   depth  =  -1

             else

                   height  =  lngconvert2(mid(strbuff,  lngpos  +  4,  2))

                   width  =  lngconvert2(mid(strbuff,  lngpos  +  6,  2))

                   depth  =  2  ^  (asc(mid(strbuff,  lngpos  +  8,  1))  *  

                   gfxspex  =  true

             end  if

                                     

         end  if

   end  function

 

 

   ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

   ':::          test  harness                                                  :::

   ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

   

   '  to  test,  we'll  just  try  to  show  all  files  with  a  .gif  extension  in  the  root  of  c:

   set  objfso  =  createobject("scripting.filesystemobject")

   set  objf  =  objfso.getfolder("c:\")

   set  objfc  =  objf.files

   response.write  "<table  border=""0""  cellpadding=""5"">"

   for  each  f1  in  objfc

       if  instr(ucase(f1.name),  ".gif")  then

             response.write  "<tr><td>"  &  f1.name  &  "</td><td>"  &  f1.datecreated  &  "</td><td>"  &  f1.size  &  "</td><td>"

             if  gfxspex(f1.path,  w,  h,  c,  strtype)  =  true  then

                   response.write  w  &  "  x  "  &  h  &  "  "  &  c  &  "  colors"

             else

                   response.write  "  "

             end  if

             response.write  "</td></tr>"

       end  if

   next

   response.write  "</table>"

   set  objfc  =  nothing

   set  objf  =  nothing

   set  objfso  =  nothing

%>

 

 

24.点击返回上页代码:

<form>

 <p><:  input type="button" value="返回上一步" onclick="history.back(-1)"></p>

</form>

 

 

 

24.点击刷新代码:

<form>

 <p><:   input type="button" value="刷新按钮一" onclick="reloadbutton()"></p>

</form>

<script language="javascript"><!--

function reloadbutton(){location.href="allbutton.htm";}

// --></script>

 

 

24.点击刷新代码2:

<form>

 <p><:  input type="button" value="刷新按钮二" onclick="history.go(0)"> </p>

</form>

 

<form>

 <p><:  input type="button" value="打开一个网站" onclick="homebutton()"></p>

</form>

 

 

 

<script language="javascript"><!--

function homebutton(){location.href=" http://nettrain.126.com";;}

// --></script>  

 

 

 

25.弹出警告框代码:

<form>

 <p><:   input type="button" value="弹出警告框" onclick="alertbutton()"></p>

</form>

<:  script language="javascript"><!--

function alertbutton(){window.alert("要多多光临呀!");}

// --></script>

 

 

 

26.状态栏信息

<form>

 <p><:   input type="button" value="状态栏信息" onclick="statusbutton()"></p>

</form>

<:   script language="javascript"><!--

function statusbutton(){window.status="要多多光临呀!";}

// --></script>

 

 

27.背景色变换

<form>

 <p><:  input type="button" value="背景色变换" onclick="bgbutton()"></p>

</form>

<:   script>function bgbutton(){

if (document.bgcolor=='#00ffff')

   {document.bgcolor='#ffffff';}

else{document.bgcolor='#00ffff';}

}

</script>

 

 

28.点击打开新窗口

<form>

 <p><:   input type="button" value="打开新窗口" onclick="newwindow()"></p>

</form>

<:    script language="javascript"><!--

function newwindow(){window.open(" http://www.mcmx.com";,"","height=240,width=340,status=no,location=no,toolbar=no,directories=no,menubar=no");}

// --></script></body>

 

 

29.分页代码:

<%''本程序文件名为:pages.asp%>

<%''包含ado常量表文件adovbs.inc,可从"\program files\common files\system\ado"目录下拷贝%>

<!--#include file="adovbs.inc"-->

<%''*建立数据库连接,这里是oracle8.05数据库

set conn=server.createobject("adodb.connection")  

conn.open "provider=msdaora.1;data source=yoursrcname;user id=youruserid;password=yourpassword;"  

set rs=server.createobject("adodb.recordset")   ''创建recordset对象

rs.cursorlocation=aduseclient                   ''设定记录集指针属性

''*设定一页内的记录总数,可根据需要进行调整

rs.pagesize=10                                    

''*设置查询语句    

strsql="select id,姓名,住址,电话 from 通讯录 order by id"        

rs.open strsql,conn,adopenstatic,adlockreadonly,adcmdtext

%>

<html>

<head>

<title>分页示例</title>

<:   script language=javascript>

//点击"[第一页]"时响应:

function pagefirst()

{

  document.myform.currentpage.selectedindex=0;

  document.myform.currentpage.onchange();

}

//点击"[上一页]"时响应:

function pageprior()

{    

  document.myform.currentpage.selectedindex--;

  document.myform.currentpage.onchange();

}

//点击"[下一页]"时响应:

function pagenext()

{

  document.myform.currentpage.selectedindex++;

  document.myform.currentpage.onchange();        

}

//点击"[最后一页]"时响应:

function pagelast()

{  

  document.myform.currentpage.selectedindex=document.myform.currentpage.length-1;

  document.myform.currentpage.onchange();

}

//选择"第?页"时响应:

function pagecurrent()

{ //pages.asp是本程序的文件名

  document.myform.action='pages.asp?page='+(document.myform.currentpage.selectedindex+1)

  document.myform.submit();

}  

</script>

</head>

<body bgcolor="#ffffcc" link="#008000" vlink="#008000" alink="#ff0000"">

 

<%if rs.eof then

  response.write("<font size=2 color=#000080>[数据库中没有记录!]</font>")

else  

  ''指定当前页码

  if request("currentpage")="" then

    rs.absolutepage=1

  else

    rs.absolutepage=clng(request("currentpage"))

  end if  

 

  ''创建表单myform,方法为get

  response.write("<form method=get name=myform>")  

  response.write("<p align=center><font size=2 color=#008000>")

  ''设置翻页超链接

  if rs.pagecount=1 then  

    response.write("[第一页] [上一页] [下一页] [最后一页] ")

  else

      if rs.absolutepage=1 then

        response.write("[第一页] [上一页] ")

        response.write("[<: href=javascript:pagenext()>下一页</a>] ")

        response.write("[<: href=javascript:pagelast()>最后一页</a>] ")

      else

          if rs.absolutepage=rs.pagecount then

            response.write("[<: href=javascript:pagefirst()>第一页</a>] ")

            response.write("[<: href=javascript:pageprior()>上一页</a>] ")

            response.write("[下一页] [最后一页] ")

          else

              response.write("[<: href=javascript:pagefirst()>第一页</a>] ")

              response.write("[<: href=javascript:pageprior()>上一页</a>] ")

              response.write("[<: href=javascript:pagenext()>下一页</a>] ")

              response.write("[<: href=javascript:pagelast()>最后一页</a>] ")

          end if

      end if

  end if

 

 

 

  ''创建下拉列表框,用于选择浏览页码

  response.write("<select size=1 name=currentpage onchange=pagecurrent()>")    

  for i=1 to rs.pagecount

    if rs.absolutepage=i then

       response.write("<option selected>"&i&"</option>")  ''当前页码

    else

       response.write("<option>"&i&"</option>")

    end if  

  next

  response.write("</select>/"&rs.pagecount&" "&rs.recordcount&"条记录</font><p>")

  response.write("</form>")

 

 

  ''创建表格,用于显示

  response.write("<table align=center cellspacing=1 cellpadding=1 border=1")    

  response.write(" bordercolor=#99ccff bordercolordark=#b0e0e6 bordercolorlight=#000066>")

 

  response.write("<tr bgcolor=#ccccff bordercolor=#000066>")

   

  set columns=rs.fields

 

 

 

  ''显示表头

  for i=0 to columns.count-1

    response.write("<td align=center width=200 height=13>")

    response.write("<font size=2><b>"&columns(i).name&"</b></font></td>")  

  next

  response.write("</tr>")

 

 

  ''显示内容

  for i=1 to rs.pagesize

    response.write("<tr bgcolor=#99ccff bordercolor=#000066>")

    for j=0 to columns.count-1

      response.write("<td><font size=2>"&columns(j)&"</font></td>")

    next

    response.write("</tr>")

   

    rs.movenext

    if rs.eof then exit for

  next

 

  response.write("</table>")

end if

%>

</body>

</html>

 

 

 

<%

验证合法email地址:

 

function isvalidemail(email)

dim names, name, i, c

isvalidemail = true

names = split(email, "@")

if ubound(names) <> 1 then

  isvalidemail = false

  exit function

end if

for each name in names

  if len(name) <= 0 then

    isvalidemail = false

    exit function

  end if

  for i = 1 to len(name)

    c = lcase(mid(name, i, 1))

    if instr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not isnumeric(c) then

      isvalidemail = false

      exit function

    end if

  next

  if left(name, 1) = "." or right(name, 1) = "." then

     isvalidemail = false

     exit function

  end if

next

if instr(names(1), ".") <= 0 then

  isvalidemail = false

  exit function

end if

i = len(names(1)) - instrrev(names(1), ".")

if i <> 2 and i <> 3 then

  isvalidemail = false

  exit function

end if

if instr(email, "..") > 0 then

  isvalidemail = false

end if

end function

%>

 

 

 

windows media player 播放器

<:  object id=mediaplayer1

           style="left: 0px; visibility: visible; position: absolute; top: 0px;z-index:2"

codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#version=5,1,52,701standby=

loading

           type=application/x-oleobject height=300 width=320

           classid=clsid:6bf52a52-394a-11d3-b153-00c04f79faa6 viewastext>

<param name="url" value="地址">

           

 <param name="audiostream" value="-1">

   <param name="autosize" value="0">

   <param name="autostart" value="-1">

   <param name="animationatstart" value="0">

   <param name="allowscan" value="-1">

   <param name="allowchangedisplaysize" value="-1">

   <param name="autorewind" value="0">

   <param name="balance" value="0">

   <param name="baseurl" value>

   <param name="bufferingtime" value="5">

   <param name="captioningid" value>

   <param name="clicktoplay" value="-1">

   <param name="cursortype" value="0">

   <param name="currentposition" value="-1">

   <param name="currentmarker" value="0">

   <param name="defaultframe" value>

   <param name="displaybackcolor" value="0">

   <param name="displayforecolor" value="16777215">

   <param name="displaymode" value="0">

   <param name="displaysize" value="4">

   <param name="enabled" value="-1">

   <param name="enablecontextmenu" value="-1">

   <param name="enablepositioncontrols" value="0">

   <param name="enablefullscreencontrols" value="0">

   <param name="enabletracker" value="-1">

   <param name="invokeurls" value="-1">

   <param name="language" value="-1">

   <param name="mute" value="0">

   <param name="playcount" value="1">

   <param name="previewmode" value="0">

   <param name="rate" value="1">

   <param name="samilang" value>

   <param name="samistyle" value>

   <param name="samifilename" value>

   <param name="selectionstart" value="-1">

   <param name="selectionend" value="-1">

   <param name="sendopenstatechangeevents" value="-1">

   <param name="sendwarningevents" value="-1">

   <param name="senderrorevents" value="-1">

   <param name="sendkeyboardevents" value="0">

   <param name="sendmouseclickevents" value="0">

   <param name="sendmousemoveevents" value="0">

   <param name="sendplaystatechangeevents" value="-1">

   <param name="showcaptioning" value="0">

   <param name="showcontrols" value="-1">

   <param name="showaudiocontrols" value="-1">

   <param name="showdisplay" value="0">

   <param name="showgotobar" value="0">

   <param name="showpositioncontrols" value="-1">

   <param name="showstatusbar" value="-1">

   <param name="showtracker" value="-1">

   <param name="transparentatstart" value="-1">

   <param name="videoborderwidth" value="0">

   <param name="videobordercolor" value="0">

   <param name="videoborder3d" value="0">

   <param name="volume" value="70">

   <param name="windowlessvideo" value="0">

</object>

 

 

 

realplayer 播放器

<:  object id=video1 classid=" clasid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa"

     width=320 height=240 align="middle">

       <param name="controls" value="inagewindow">

       <param name="console" value="chicp1">

       <param name="autostar" value="true">

       <param name="src" value="地址">

       <embed        

                src="地址"          

              type="audio/x-pn-realaudio-plugin" console="chip1"                

        controls="imagewindow" width=320 height=240 autostart=true align="middle">

       </embed>

     </object>

 

 

 

<:  script language="vbscript">        

a=msgbox("真的要删除该记录吗?",1,"注意")

if a=1 then

 location="dodelete.asp?id=<%=id%>"           //指向执行删除的页面dodelete.asp

 else

 history.go(-1)

end if

</script>

 

 

 

其中id=<%=id%>是指从表单中取得的数据编号,当然也可以是其他的东东。

asp打印

var strfeature="height=360,width=500,status=no,toolbar=no,resizable=no,menubar=no,location=no";

var awin = window.open("","print",strfeature);

awin.document.open();

awin.document.write("<html>");

awin.document.write("<head>");

awin.document.write("<title>打印服务</title>");

awin.document.write("</head>");

awin.document.write("<body onload='window.print();window.close();'>");

awin.document.write("<img src=" + document.mvimage.src +">");

awin.document.write("<font size='0'>");

awin.document.write("<br><br>版权所有 郑州达维计算机技术有限公司</a>  ");

awin.document.write(" http://www.zzdw.com";;);

awin.document.write("</font>");

awin.document.write("</body>");

awin.document.write("</html>");

awin.document.close();  

输入框加背景色<:   input style='background-color:red'>在加入type="xxx"可以为其它的控件加入背景颜色。

下拉菜单变背景色

<:  select name="select">

 <option style="background-color:#f0f0f0">111111111</option>

 <option style="background-color:#cccccc">111111111</option>

</select>

 

 

 

两个下拉表单相互关联

<form name="doublecombo">

<:   select name="example" size="1" onchange="redirect(this.options.selectedindex)">

<option>阳光在线</option>

<option> www.sunness.com</option>

<option>sunness.com</option>

</select>

<:   select name="stage2" size="1">  

<option value=" http://www.80cn.com";;>阳光在线</option>

</select>

<:    input type="button" name="test" value="go!"  

onclick="go()">  

</p>  

 

 

<  script>  

<!--  

var groups=document.doublecombo.example.options.length  

 var group=new array(groups)  

 for (i=0; i<groups; i++)  

 group[i]=new array()  

group[0][0]=new option("阳光在线"," http://www.sunness.com";  

 

 

group[1][0]=new option("阳光在线"," http://www.sunness.com";  

 group[1][1]=new option("sunness"," http://www.sunness.com";   

 group[1][2]=new option("sunness.com"," http://www.sunness.com";  

 

group[2][0]=new option("aaat"," http://www.sunness.com";  

 group[2][1]=new option("bbb"," http://www.sunness.com";  

 group[2][2]=new option("ddd"," http://www.sunness.com";  

 group[2][3]=new option("ccc"," http://www.sunness.com";  

var temp=document.doublecombo.stage2  

function redirect(x){  

 for (m=temp.options.length-1;m>0;m--)  

 temp.options[m]=null  

 for (i=0;i<group[x].length;i++){  

 temp.options[i]=new option(group[x][i].text,group[x][i].value)  

 }  

 temp.options[0].selected=true  

 }  

function go(){  

 location=temp.options[temp.selectedindex].value  

 }  

 //-->  

 </script>  

 </form>

 

 

 

1. 如何在网页中加入注释

◆代码:< !-- 这是注释 --> 

 

 

 

2. 如何在网页中加入email链接并显示预定的主题

◆代码:<:   a href="mailto:yourmail@xxx.xxx?subject=你好">send mail< /a>

 

 

 

3. 如何制作电子邮件表单

◆在<form>中输入action="youremail@xxx.xxx" ,提交采用post方法。

 

 

 

4. 如何避免别人将你的网页放入他的框架(frame)中

◆在源代码中的<head>< /head>之间加入如下代码:

<:   s cript language="javas cript"><!--

if (self!=top){top.location=self.location;}

-->< /s cript>

 

 

 

5. 如何自动加入最后修改日期

◆在源代码中的<body>< /body>之间加入如下代码:

< s cript language="javas cript"><!--

document.write("last updated:"+document.lastmodified);

-->< /s cript>

 

 

6. 如何让背景图象不滚动

◆代码:<:   body background="bg.gif" bgproperties="fixed" >

◆在dreamweaver中用「text-custom style-edit style sheet-new-redefine html tag中选择body,然后在background中的attachment里选fixed

 

 

7. 如何将网页定时关闭

◆在源代码中的<body>后面加入如下代码:

<:     s cript language="javas cript"> <!--

settimeout('window.close();', 60000);

--> < /s cript>

在代码中的60000表示1分钟,它是以毫秒为单位的。

 

 

 

8. 将网页加入收藏夹

◆请使用如下代码:(注意标点符号)

<:    a href='#' onclick="window.external.addfavorite(' http://qiangwei.126.com','【梦想天空】qiangwei.126.com 各种网页工具教程dwflashfireworkscgi教学、聊天交友……')" target="_top">将本站加入收藏夹< /a>

 

 

9. 如何定义网页的关键字(keywords)

◆格式如下:

<:    meta name="keywords" content="dreamweaver,flash,fireworks">

content中的即为关键字,用逗号隔开

◆在dreamweaver中用「insert-head-keywords命令

 

 

 

10. 如何设置命令来关闭打开的窗口

◆在源代码中加入如下代码:

<:    a href="/" onclick="javas cript:window.close(); return false;">关闭窗口< /a>

 

 

11. 如何在网页中加入书签,在页面内任意跳转

◆在源代码中需要插入书签的地方输入,在调用的地方输入top,其中的top是你设定的书签名字。

◆在dreamweaver中用菜单的「insert-name anchor」命令插入书签,调用时,在link中输入#toptop为书签名。

 

 

 

12. 如何为不支持框架的浏览器指定内容

◆在源代码中加入下面代码:

< body><noframes>本网页有框架结构,请下载新的浏览器观看< /noframes></ body>

 

 

13. 如何在网页中加入单个或几个空格

◆在源代码中输入 ,每个 之间请用空格分开。

◆在dreamweaver中用<ctrl>+<shift>+<space>插入空格或任输几个字符,然后将其色彩设成背景的色彩!

 

 

14. 如何在网页中加入书签,在多个页面之间任意跳转

◆方法与上面类似,不过做链接时要在书签名前加上网页文件名,如:other.htm#top,这样一来就会跳转到other.htm页面中的top书签处。

 

 

 

15. 如何使表格(table)没有边框线

◆将表格的边框属性:border="0"

 

 

16. 如何隐藏状态栏里出现的link信息

◆请使用如下代码:

<:   a href=" http://qiangwei.126.com";; onmouseover="window.status='none';return true">梦想天空< /a>

 

 

 

17. 如何定时载入另一个网页内容

◆在源代码中的<head>< /head> 加入如下代码:

<:   meta http-equiv="refresh" content="40;url=http://qiangwei.126.com">

40秒后将自动 http://qiangwei.126.com所在的网页

 

 

18. 如何为网页设置背景音乐

◆代码:<:   embed src="music.mid" autostart="true" loop="2" width="80" height="30" >

src:音乐文件的路径及文件名;

autostarttrue为音乐文件上传完后自动开始播放,默认为false(否)

looptrue为无限次重播,false为不重播,某一具体值(整数)为重播多少次

volume:取值范围为"0-100",设置音量,默认为系统本身的音量

starttime"分:秒",设置歌曲开始播放的时间,如,starttime="00:10",从第10开始播放

endtime "分:秒",设置歌曲结束播放的时间

width:控制面板的宽

height:控制面板的高

controls:控制面板的外观

controls="console/smallconsole/playbutton/pausebutton/stopbutton/volumelever"

console:正常大小的面板

smallconsole:较小的面板

playbutton:显示播放按钮

pausebutton:显示暂停按钮

stopbutton:显示停止按钮

volumelever:显示音量调节按钮

hidden:为true时可以隐藏面板

 

 

19. 如何去掉链接的下划线

◆在源代码中的<head></head>之间输入如下代码:

<style type="text/css"> <!--

a { text-decoration: none}

--> < /style>

◆在dreamweaver中用「text-custom style-edit style sheet-new-redefine html tag中选择a,然后在decoration中选中none

 

 

 

20. timeline中的layer走曲线

◆要使得timeline中的layer走曲线,你得先让他走出直线来,然后在最后一frame和第一frame中间的任何一frame上点右键,可以看到有个 add keyframe ,点一下,然后把你的layer移动到你要的位置,dw会自动生成曲线,good luck !

 

 

 

posted on 2005-09-13 12:32 Alpha 阅读(1120) 评论(0)  编辑  收藏 所属分类: JavaScript

只有注册用户登录后才能发表评论。


网站导航: