初学者往往对业务逻辑上和结构上并没有什么概念,这个阶段还停留在视觉体验或者功能实现的基础上,那么如何让初学者的代码迅速提高前台表现能力呢,这里我整理了一些常用的代码,供大家学习。

----------------------------

初级篇 1.让文字不停地滚动

  <MARQUEE>滚动文字</MARQUEE>

  2.记录并显示网页的最后修改时间

  <script language=JavaScript>
  document.write("最后更新时间: " + document.lastModified + ""
  </script>

  3.关闭当前窗口

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

  4.2秒后关闭当前页

  <script language="JavaScript">
  <!--
  setTimeout('window.close();',2000);
  -->
  </script>

  5.2秒后载入指定网页

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

  6.添加到收藏夹

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

  7.让超链接不显示下划线

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

  8.禁止鼠标右键的动作

  <Script Language = "JavaScript">
  function click() { if (event.button==2event.button==3)
  {
  alert('禁止鼠标右键');
  }
  document.οnmοusedοwn=click // -->
  </Script>

  9.设置该页为首页

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

中级篇

节日倒计时

<Script Language="JavaScript">
  var timedate= new Date("October 1,2005";
  var times="国庆节";
  var now = new Date();
  var date = timedate.getTime() - now.getTime();
  var time = Math.floor(date / (1000 * 60 * 60 * 24));
  if (time >= 0)
  document.write("现在离"+times+"还有: "+time +"天"</Script>
显示系统当前日期
<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 }
  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>

高级篇

  1.不同时间段显示不同问候语

  <Script Language="JavaScript">
  <!--
  var text=""; day = new Date( ); time = day.getHours( );
  if (( time>=0) && (time < 7 ))
    text="夜猫子,要注意身体哦! "
  if (( time >= 7 ) && (time < 12))
    text="今天的阳光真灿烂啊,你那个朋友呢?"
  if (( time >= 12) && (time < 14))
    text="午休时间。您要保持睡眠哦!"
  if (( time >=14) && (time < 18))
    text="祝您下午工作愉快! "
  if ((time >= 18) && (time <= 22))
    text="您又来了,可别和MM聊太久哦!"
  if ((time >= 22) && (time < 24))
    text="您应该休息了!"
  document.write(text)
  //--->
  </Script>

  2.水中倒影效果

  <img id="reflect" src="你自己的图片文件名" width="175" height="59">
  <script language="JavaScript">
  function f1()
  {
    setInterval("mdiv.filters.wave.phase+=10",100);
  }
  if (document.all)
  {
    document.write('<img id=mdiv src="'+document.all.reflect.src+'"
    >')
    window.οnlοad=f1
  }
  </script>

  3.慢慢变大的窗口

  <Script Language="JavaScript">
  <!--
  var Windowsheight=100
  var Windowswidth=100
  var numx=5
  function openwindow(thelocation){
  temploc=thelocation
  if
  (!(window.resizeTo&&document.all)&&!(window.resizeTo&&document.getElementById))
  {
    window.open(thelocation)
    return
  }
  windowsize=window.open("","","scrollbars"
  windowsize.moveTo(0,0)
  windowsize.resizeTo(100,100)
  tenumxt()
  }
  function tenumxt(){
  if (Windowsheight>=screen.availHeight-3)
    numx=0
  windowsize.resizeBy(5,numx)
  Windowsheight+=5
  Windowswidth+=5
  if (Windowswidth>=screen.width-5)
  {
    windowsize.location=temploc
    Windowsheight=100
    Windowswidth=100
    numx=5
    return
  }
  setTimeout("tenumxt()",50)
  }
  //-->
  </script>
  <p><a href="javascript penwindow('http://www.ccjol.com')">进入</a>

  4.改变IE地址栏的IE图标

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

  <link REL = "Shortcut Icon" href="index.ico">

5.让网页随意后退

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

  6.鼠标指向时弹出信息框

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

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

  7.单击鼠标右键弹出添加收藏夹对话框

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

  <Script Language=JavaScript>
  if (document.all)
  document.body.οnmοusedοwn=new Function("if (event.button==2event.button==3)
  window.external.addFavorite('您的网址','您的网站名称)"
  </Script>

  8.随机变换背景图象(一个可以刷新心情的特效)

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

  <Script Language="JavaScript">
  image = new Array(4); //定义image为图片数量的数组
  image [0] = 'tu0.gif' //背景图象的路径
  image [1] = 'tu1.gif'
  image [2] = 'tu2.gif'
  image [3] = 'tu3.gif'
  image [4] = 'tu4.gif'
  number = Math.floor(Math.random() * image.length);
  document.write("<BODY BACKGROUND="+image[number]+">";
  </Script>

  9.鼠标一碰就给颜色看的链接

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

  <p onMouseMove="anniu()">你敢碰我,我就给点颜色你看!</p>
  <Script Language = "VBScript">
  sub anniu
  document.fgColor=int(256*256*256*rnd)
  end sub
  </Script>

  10.从天而降并有幻影效果的窗口

  <head>
  <Script language="JavaScript">
  function move(x) {
  if(self.moveBy){
  self.moveBy (0,-800);
  for(i = x; i > 0; i--)
  {
  self.moveBy(0,3);
  }
  for(j = 200; j > 0; j--){ //如果你认为窗口抖动厉害,就200换成个位数
  self.moveBy(0,j);
  self.moveBy(j,0);
  self.moveBy(0,-j);
  self.moveBy(-j,0);
  }
  }
  }
  </Scrip>
  <body bgColor=#ffffff οnlοad=move(280)>
  </body>
  </head>

  11.表格的半透明显示效果

  在<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>

JS常用代码

1.网页按钮的特殊颜色
<input type=button name="Submit1" value="按钮" size=10 class="s02" >

2.鼠标移入移出时颜色变化
<input type="submit" value="找吧" name="B1" onMouseOut=this.style.color="blue" onMouseOver=this.style.color="red"  class="button">

3.平面按钮
<input type=submit value=订阅 name="submit">

4.按钮颜色变化
<input type=text name="nick"   size="15" maxlength="16">

5.平面输入框
<input type="text" name="T1" size="20" >

6.使窗口变成指定的大小
<script>
window.resizeTo(300,283);
</script>

7.使文字上下滚动
<marquee direction=up scrollamount=1 scrolldelay=100 οnmοuseοver='this.stop()' οnmοuseοut='this.start()' height=60>
<!-- head_scrolltext -->
<tr>
<td>
上下滚动的文字
</table>        <!-- end head_scrolltext -->
</marquee>

8.点击文字实现radio选项的选定
<br>
    <input type="radio" name="regtype" value="A03" id="A03">
<label for="A03"> 你好: 欢迎光临</label> <br>

9.线型输入框
<input type="text" name="key"  size="12" value="关键字" onFocus=this.select() onMouseOver=this.focus() class="line">

10.显示文档最后修改日期
<script language=javascript>
function hi(str)
{
document.write(document.lastModified)
alert("hi"+str+"!"
}
</script>

11.可以在鼠标移到文字上时就触发事件
<html>
<head>
<script language="LiveScript">
<!-- Hiding
    function hello() {
      alert("哈罗!";
    }
</script>
</head>
<body>
<a href="" onMouseOver="hello()">link</a>
</body>
</html>

12.可以根据网页上的选项来确定页面颜色
<HTML>
<HEAD>
<TITLE>background.html</TITLE>
</HEAD>
<SCRIPT>
<!--

function bgChange(selObj) {
newColor = selObj.options[selObj.selectedIndex].text;
document.bgColor = newColor;
selObj.selectedIndex = -1;
}

//-->
</SCRIPT>
<BODY STYLE="font-family:Arial">
<B>Changing Background Colors</B>
<BR>
<FORM>
  <Select SIZE="8" onChange="bgChange(this);">
  <OPTION>Red
  <OPTION>Orange
  <OPTION>Yellow
  <OPTION>Green
  <OPTION>Blue
  <OPTION>Indigo
  <OPTION>Violet
  <OPTION>White
<OPTION>pink
  </Select>
</FORM>
</BODY>
</HTML>

13.将按钮的特征改变
<style type="text/CSS">
<!--
.style1 { font-size: 12px; background: #CCCCFF; border-width: thin thin thin thin; border-color: #CCCCFF #CCCCCC #CCCCCC #CCCCFF}
.style2 { font-size: 12px; font-weight: bold; background: #CCFFCC; border-width: thin medium medium thin; border-color: #CCFF99 #999999 #999999 #CCFF99}
-->
</style>
本例按钮的代码如下:
<input type="submit" name="Submit" value="提 交" οnmοuseοver="this.className='style2'"
οnmοuseοut="this.className='style1'" class="style1">

14.改变按钮的图片.
<style type="text/css">
<!--
.style3 { font-size: 12px; background: url(image/buttonbg1.gif); border: 0px; width: 60px; height: 22px}
.style4 { font-size: 12px; font-weight: bold; background: url(image/buttonbg2.gif); border: 0px 0; width: 60px; height: 22px}
-->
</style>
本例的按钮代码如下:
<input type="submit" name="Submit2" value="提 交" οnmοuseοver="this.className='style4'"
οnmοuseοut="this.className='style3'" class="style3">

15.改变下拉框的颜色
<select name="classid"
onChange="changelocation(document.myform.classid.options[document.myform.classid.selectedIndex].value)" size="1" >

16.转至目标URL
window.location="http://www.cxblog.net"

17.过10秒自动关闭页面
< script language="JavaScript" >
function closeit() {
setTimeout("self.close()",10000)
}
< /script >

18.可以比较字符的大小
char=post.charAt(i);
if(!('0'<=char&&char<='9'))

19.将字符转化为数字
month = parseInt(char)

20.点击value非空的选项时转向指定连接
<select οnchange='if(this.value!=""window.open(this.value)' class="textinput">
    <option selected>主办单位</option>
    <option>-----------------</option>
    <option value="http://www.bjd.com.cn/">北京日报</option>
    <option value="http://www.ben.com.cn/">北京晚报</option>
</select>

21.改变文字输入框的背景颜色
<style>
.input2 {background-image: url('../images/inputbg.gif');  font-size: 12px; background-color: #D0DABB;border-top-width:1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
</style>
<input name=content type=text size="47" class="input2" maxlength="50">

22.改变水平线的特征
<hr size="0" noshade color="#C0C0C0">

23.两个按键一起按下
if(event.ctrlKey && window.event.keyCode==13)//

24.刷新页面
javascript :this.location.reload()//

25.双击网页自动跑
<SCRIPT LANGUAGE="JavaScript">
var currentpos,timer;
function initialize()
{
timer=setInterval("scrollwindow()",1);
}
function sc()
{
clearInterval(timer);
}
function scrollwindow()
{
currentpos=document.body.scrollTop;
window.scroll(0,++currentpos);
if (currentpos != document.body.scrollTop)
  sc();
}
document.οnmοusedοwn=sc
document.οndblclick=initialize
</SCRIPT>//

26.后退
<INPUT TYPE="button" οnclick=window.history.back() value=back>

27.前进
<INPUT TYPE="button" οnclick=window.history.forward() value=forward>

28.刷新
<INPUT TYPE="button" οnclick=document.location.reload() value=reload>

29.在网页上显示实时时间
<SCRIPT LANGUAGE="JavaScript">
var clock_id;
window.οnlοad=function()
{
clock_id=setInterval("document.form1.txtclock.value=(new Date);",1000)
}
</SCRIPT>//

30.可以改变页面上的连接的格式,使其为双线
<style>
A:link {text-decoration: none; color:#0000FF; font-family: 宋体}
A:visited {text-decoration: none; color: #0000FF; font-family: 宋体}
A:hover {text-decoration: underline overline; color: FF0000}
</style>

<style>
A:link {text-decoration: none; color:#0000FF; font-family: 宋体}
A:visited {text-decoration: none; color: #0000FF; font-family: 宋体}
A:hover {text-decoration: underline overline line-through; color: FF0000}
TH{FONT-SIZE: 9pt}
TD{FONT-SIZE: 9pt}
body {SCROLLBAR-FACE-COLOR: #A9D46D; SCROLLBAR-HIGHLIGHT-COLOR: #e7e7e7;SCROLLBAR-SHADOW-COLOR:#e7e7e7; SCROLLBAR-3DLIGHT-COLOR: #000000; LINE-HEIGHT: 15pt; SCROLLBAR-ARROW-COLOR: #ffffff; SCROLLBAR-TRACK-COLOR: #e7e7e7;}

INPUT{BORDER-TOP-WIDTH: 1px; PADDING-RIGHT: 1px; PADDING-LEFT: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 9pt; BORDER-LEFT-COLOR: #cccccc; BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: #cccccc; PADDING-BOTTOM: 1px; BORDER-TOP-COLOR: #cccccc; PADDING-TOP: 1px; HEIGHT: 18px; BORDER-RIGHT-WIDTH: 1px; BORDER-RIGHT-COLOR: #cccccc}
DIV,form ,OPTION,P,TD,BR{FONT-FAMILY: 宋体; FONT-SIZE: 9pt}
textarea, select {border-width: 1; border-color: #000000; background-color: #efefef; font-family: 宋体; font-size: 9pt; font-style: bold;}
.text { font-family: "宋体"; font-size: 9pt; color: #003300; border: #006600 solid; border-width: 1px 1px 1px 1px}
</style>完整的css

31.直线型输入框
<INPUT name=Password size=10 type=password >

32.以下是一个完整的显示hint的代码,其思想是当鼠标停留是将div中的内容显示在鼠标出,当鼠标移出后在将该div隐藏掉
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<style>
#hint{
width:198px;
border:1px solid #000000;
background:#99ff33;
position:absolute;
z-index:9;
padding:6px;
line-height:17px;
text-align:left;
top: 1520px;
}
</style>
<SCRIPT LANGUAGE="JavaScript">
<!--
function showme()
{
var oSon=window.document.getElementById("hint");
if (oSon==null) return;
with (oSon)
{
  innerText=guoguo.value;
  style.display="block";
  style.pixelLeft=window.event.clientX+window.document.body.scrollLeft+6;
  style.pixelTop=window.event.clientY+window.document.body.scrollTop+9;
}
}
function hidme()
{
var oSon=window.document.getElementById("hint");
if (oSon==null) return;
oSon.style.display="none";
}
//-->
</SCRIPT>
<BODY>
<text id=guoguo value=ga>
<a href=# οnmοuseοver=showme() οnmοuseοut=hidme() οnmοusemοve=showme() son=hint>dfdfd</a>
<div id=hint ></div>
</BODY>
</HTML>
-------------------------------------------------------------------------

33.弹出窗口
方法一:<body οnlοad="openwen()"> 浏览器读页面时弹出窗口;
方法二:<body οnunlοad="openwen()"> 浏览器离开页面时弹出窗口;
方法三:用一个连接调用:<a href="#" οnclick="openwin()">打开一个窗口</a>
注意:使用的"#"是虚连接。
方法四:用一个按钮调用:<input type="button" οnclick="openwin()" value="打开窗口"> 何时装载script

34.判断是何种浏览器
var name = navigator.appName;
if (name == "Microsoft Internet Explorer")
alert("IE");
else if (name == "Netscape")
alert("NS");//

35.最小化窗口
window.blur()//

36.设置为主页
function makeHome(){
  netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesWrite");
  navigator.preference("browser.startup.homepage", location.href);
}//

37.设置为收藏
function addFav(){
  if(ie)
    window.external.AddFavorite(location.href,'WWW.OGRISH.COM : GROTESQUE MOVIES AND PICTURES');
  if(ns)
    alert("Thanks for the bookmark!\n\nNetscape users click OK then press CTRL-D");
}//

38.判断cookie是否可用
navigator.cookieEnabled;//

39.禁止选择页面上的文字来拷贝
<script>
function noEffect() {
  with (event) {
    returnValue = false;
    cancelBubble = true;
  }
  return;
}
</script>
<body onselectstart="noEffect()" οncοntextmenu="noEffect()">//

40.屏蔽右键菜单
οncοntextmenu="event.returnValue = false"//

41.禁止在输入框打开输入法
<input >//

42.屏蔽汉字和空格
<input name="txt"><input type="submit" onClick="alert(!/[^ -}]|\s/.test(txt.value))">//

43.获得当前的文本框选中的文字
<input οnmοuseup="alert(document.selection.createRange().text)" value=123>//

44.跳转至目标页面,同时不可返回
<a href="javascript :location.replace('http://www.sohu.com/')">sohu.com</a>//

45.打开C盘
<form action="file:///c|/"><input type="submit" value="c:\ drive"></form>//

46.当前屏幕的分辨率
screen.width、screen.height//

47.本地快捷键
<a href="file:///::{208D2C60-3AEA-1069-A2D7-08002B30309D}" target="_blank">网上邻居</a>
<a href="file:///::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\d:\web" target="_blank">我的电脑</a>
<a href="file:///::{450D8FBA-AD25-11D0-98A8-0800361B1103}" target="_blank">我的文档</a>
<a href="file:///::{645FF040-5081-101B-9F08-00AA002F954E}" target="_blank">回收站</a>
<a href="file:///::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{21EC2020-3AEA-1069-A2DD-08002B30309D}" target="_blank">控制面板</a>
<a href="file:///::{7007ACC7-3202-11D1-AAD2-00805FC1270E}">拨号网络</a>(Windows 2000)

48.IE菜单
<button οnclick="min.Click()"><font face="webdings">0</font></button>//改变按钮上的图片
<input type=button  οnclick="document.execCommand('CreateLink','true','true')"> //创建新连接
<input type=button  οnclick="document.execCommand('print','true','true')"> //打印
<input type=button  οnclick="document.execCommand('saveas','true','网站制作.htm')">//另存为htm
<input type=button  οnclick="document.execCommand('saveas','true','网站制作.txt')">//另存为txt
document.execCommand("SaveAs")//保存为
document.execCommand('undo')//撤销上一次操作

49.web对话框
<SCRIPT>
var contents='<style>body,td{font:menu}img{cursor:hand}</style>';
contents+='<title>你要关闭我吗</title>';
contents+='<body bgcolor=menu>';
contents+='<table width=100% height=100% border=0>';
contents+='<tr><td align=center>';
contents+='你要关闭我吗?<br>';
contents+='<img src=dark.gif οnclick=self.close() alt="...关闭">';
contents+='<img src=jet.gif οnclick=self.close() alt="全是关闭">';
contents+='</td></tr></table>';
showModalDialog("about:"+contents+"","","dialogHeight:50px;dialogWidth:250px;help:no;status:no")
document.write(contents);
</SCRIPT>//

50.鼠标移到下拉框时自动全部打开
<select οnmοuseοver="javascript :this.size=this.length" οnmοuseοut="javascript :this.size=1"></select>//

51.一个特殊的容器,想装个网页都行
<button><iframe src="http://www.google.com/"></iframe></button>//button

52.页面翻转
<html dir=rtl></html>//

53.滚屏
parent.scroll(x,y);//
<body οnlοad="s=0" onDblClick="s=setInterval('scrollBy(0, 1)',10)" onClick="clearInterval(s)">//

54.改变状态栏
self.status ="";//

55.改变鼠标样式
style
BODY{CURSOR: url('mouse.ani');
SCROLLBAR-BASE-COLOR: #506AA8;
SCROLLBAR-ARROW-COLOR: #14213F;
}//

56.背景透明
<input type="button" value="Button" >//

57.获得操作系统的名称和浏览器的名称
document.write(navigator.userAgent)//

58.滚动条滚动
<button οnclick="text1.scrollTop=text1.scrollHeight">Scroll</button><br>
<textarea id="text1" cols=50 rows=10>
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
</textarea>//

59.让下拉框自动下拉
<select οnmοuseοver="javascript :this.size=this.length" οnmοuseοut="javascript :this.size=1">
<option value="">1</option>
<option value="">2</option>
<option value="">3</option>
</select> //

60.判断一个数字是否是整数
var a=23.2;
alert(a%1==1)//

61.新建日期型变量
var a = new Date(2000, 1, 1);
alert(a.toLocaleDateString());

62.生成Excel文件并保存
var ExcelSheet;
ExcelApp = new ActiveXObject("Excel.Application");
ExcelSheet = new ActiveXObject("Excel.Sheet");
//本代码启动创建对象的应用程序(在这种情况下,Microsoft Excel 工作表)。一旦对象被创建,就可以用定义的对象变量在代码中引用它。 在下面的例子中,通过对象变量 ExcelSheet 访问新对象的属性和方法和其他 Excel 对象,包括 Application 对象和 ActiveSheet.Cells 集合。
// 使 Excel 通过 Application 对象可见。
ExcelSheet.Application.Visible = true;
// 将一些文本放置到表格的第一格中。
ExcelSheet.ActiveSheet.Cells(1,1).Value = "This is column A, row 1";
// 保存表格。
ExcelSheet.SaveAs("C:\\TEST.XLS");
// 用 Application 对象用 Quit 方法关闭 Excel。
ExcelSheet.Application.Quit();//

63.实现打印预览及打印
<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=wb name=wb width=0></OBJECT>
<input type=button value=打印预览 οnclick="wb.execwb(7,1)">
<input type=button onClick=document.all.wb.ExecWB(6,1) value="打印">//

64.不通过form,直接通过名字引用对象
<INPUT TYPE="text" NAME="gg" value=aaaaa>
<SCRIPT LANGUAGE="JavaScript">
<!--
alert(document.all.gg.value)
//-->
</SCRIPT>//

65.使鼠标滚轮失效
function document.onmousewheel()
{
return false;
}//

66.将数字转化为人民币大写形式
function convertCurrency(currencyDigits) {
// Constants:
var MAXIMUM_NUMBER = 99999999999.99;
// Predefine the radix characters and currency symbols for output:
var CN_ZERO = "零";
var CN_ONE = "壹";
var CN_TWO = "贰";
var CN_THREE = "叁";
var CN_FOUR = "肆";
var CN_FIVE = "伍";
var CN_SIX = "陆";
var CN_SEVEN = "柒";
var CN_EIGHT = "捌";
var CN_NINE = "玖";
var CN_TEN = "拾";
var CN_HUNDRED = "佰";
var CN_THOUSAND = "仟";
var CN_TEN_THOUSAND = "万";
var CN_HUNDRED_MILLION = "亿";
var CN_SYMBOL = "人民币";
var CN_DOLLAR = "元";
var CN_TEN_CENT = "角";
var CN_CENT = "分";
var CN_INTEGER = "整";

// Variables:
var integral; // Represent integral part of digit number.
var decimal; // Represent decimal part of digit number.
var outputCharacters; // The output result.
var parts;
var digits, radices, bigRadices, decimals;
var zeroCount;
var i, p, d;
var quotient, modulus;

// Validate input string:
currencyDigits = currencyDigits.toString();
if (currencyDigits == "") {
  alert("Empty input!");
  return "";
}
if (currencyDigits.match(/[^,.\d]/) != null) {
  alert("Invalid characters in the input string!");
  return "";
}
if ((currencyDigits).match(/^((\d{1,3}(,\d{3})*(.((\d{3},)*\d{1,3}))?)|(\d+(.\d+)?))$/) == null) {
  alert("Illegal format of digit number!");
  return "";
}

// Normalize the format of input digits:
currencyDigits = currencyDigits.replace(/,/g, ""); // Remove comma delimiters.
currencyDigits = currencyDigits.replace(/^0+/, ""); // Trim zeros at the beginning.
// Assert the number is not greater than the maximum number.
if (Number(currencyDigits) > MAXIMUM_NUMBER) {
  alert("Too large a number to convert!");
  return "";
}

// [url]http://www.cxblog.net/[/url] Process the coversion from currency digits to characters:
// Separate integral and decimal parts before processing coversion:
parts = currencyDigits.split(".");
if (parts.length > 1) {
  integral = parts[0];
  decimal = parts[1];
  // Cut down redundant decimal digits that are after the second.
  decimal = decimal.substr(0, 2);
}
else {
  integral = parts[0];
  decimal = "";
}
// Prepare the characters corresponding to the digits:
digits = new Array(CN_ZERO, CN_ONE, CN_TWO, CN_THREE, CN_FOUR, CN_FIVE, CN_SIX, CN_SEVEN, CN_EIGHT,

CN_NINE);
radices = new Array("", CN_TEN, CN_HUNDRED, CN_THOUSAND);
bigRadices = new Array("", CN_TEN_THOUSAND, CN_HUNDRED_MILLION);
decimals = new Array(CN_TEN_CENT, CN_CENT);
// Start processing:
outputCharacters = "";
// Process integral part if it is larger than 0:
if (Number(integral) > 0) {
  zeroCount = 0;
  for (i = 0; i < integral.length; i++) {
  p = integral.length - i - 1;
  d = integral.substr(i, 1);
  quotient = p / 4;
  modulus = p % 4;
  if (d == "0") {
    zeroCount++;
  }
  else {
    if (zeroCount > 0)
    {
    outputCharacters += digits[0];
    }
    zeroCount = 0;
    outputCharacters += digits[Number(d)] + radices[modulus];
  }
  if (modulus == 0 && zeroCount < 4) {
    outputCharacters += bigRadices[quotient];
  }
  }
  outputCharacters += CN_DOLLAR;
}
// Process decimal part if there is:
if (decimal != "") {
  for (i = 0; i < decimal.length; i++) {
  d = decimal.substr(i, 1);
  if (d != "0") {
    outputCharacters += digits[Number(d)] + decimals;
  }
  }
}
// Confirm and return the final output string:
if (outputCharacters == "") {
  outputCharacters = CN_ZERO + CN_DOLLAR;
}
if (decimal == "") {
  outputCharacters += CN_INTEGER;
}
outputCharacters = CN_SYMBOL + outputCharacters;
return outputCharacters;
}//

67.取月的最后一天
function getLastDay(year,month)
{
//取年
var new_year = year;
//取到下一个月的第一天,注意这里传入的month是从1~12
var new_month = month++;
//如果当前是12月,则转至下一年
if(month>12)
{
  new_month -=12;
  new_year++;
}
var new_date = new Date(new_year,new_month,1);
return (new Date(new_date.getTime()-1000*60*60*24)).getDate();
}//

68.给下拉框分组
<Select>
<OPTGROUP LABEL="碱性金属">
<OPTION>锂 (Li)</OPTION>
<OPTION>纳 (Na)</OPTION>
<OPTION>钾 (K)</OPTION>
</OPTGROUP>
<OPTGROUP LABEL="卤素">
<OPTION>氟 (F)</OPTION>
<OPTION>氯 (Cl)</OPTION>
<OPTION>溴 (Br)</OPTION>
</OPTGROUP>
</Select>//

69.加注音
<RUBY>
基准文本
<RT>注音文本
</RUBY>//

70.加删除线
<S>此文本将带删除线显示。</S>//

71.防止链接文字折行
document.body.noWrap=true;//

72. 弹出新页面,关闭旧页面,不弹出提示框
  var w=screen.availWidth-10;
  var h=screen.availHeight-10;
  var swin=window.open("/mc/mc/message_management.jsp", "BGSMbest","scrollbars=yes,status,location=0,menubar=0,toolbar=0,resizable=no,top=0,left=0,height="+h+",width="+w);
  window.opener=null;
  window.close();//

73.能输入的下拉框
<span>
<input name="Department1" id="Department1" autocomplete="off">
<span >
<select   onChange="Department1.value=value">
<option value=""></option>
<option value="asdfasfadf">asdfasfadf</option>
<option value="546546">546546</option></select> //

74.图片加载失败时重新加载图片
<img src="aa.gif" οnerrοr="this.src='aa.gif'">//

1、建立一个htm文件,如:hotad.htm 放到贵站根目录
2、到热点后台取得新代码,并将新代码放到hotad.htm文件里
3、建立一个JS文件 如:ad01.js 放到贵站根目录
4、插入以下代码到 ad01.js

//以下是ad01.js的代码
document.write('')
document.write('  ')
//下面这行就是放置广告代码的页面,请注意 width="468" height="60" 是嵌入页面的宽度和高度
document.write('  ')
document.write('
')
document.write('  ')
//JS代码结束

说明:以上代码需要修改以下2个部分:
(1) width="468" height="60" 这2个数值根据广告位模式更改
(2) [url]http://www.abc.com/[/url] 换成贵站网址

5、在欲投放广告的地方插入JS。
  比如在某网页中插入:

全站使用这样的方式投放广告,那么无论更换广告代码是多么的频繁,每次更换也只需要一分种。
用iframe调用的好处是不会因为广告的显示速度慢影响网站的显示速度。

-----------------------------

event.clientX 返回最后一次点击鼠标X坐标值;
event.clientY 返回最后一次点击鼠标Y坐标值;
event.offsetX 返回当前鼠标悬停X坐标值
event.offsetY 返回当前鼠标悬停Y坐标值
document.write(document.lastModified) 网页最后一次更新时间
document.οndblclick=x 当双击鼠标产生事件
document.οnmοusedοwn=x 单击鼠标键产生事件
document.body.scrollTop; 返回和设置当前竖向滚动条的坐标值,须与函数配合,
document.body.scrollLeft; 返回和设置当前横向滚动务的坐标值,须与函数配合,
document.title document.title="message"; 当前窗口的标题栏文字
document.bgcolor document.bgcolor="颜色值"; 改变窗口背景颜色
document.Fgcolor document.Fgcolor="颜色值"; 改变正文颜色
document.linkcolor document.linkcolor="颜色值"; 改变超联接颜色
document.alinkcolor document.alinkcolor="颜色值"; 改变正点击联接的颜色
document.VlinkColor document.VlinkColor="颜色值"; 改变已访问联接的颜色
document.forms.length 返回当前页form表单数
document.anchors.length 返回当前页锚的数量
document.links.length 返回当前页联接的数量
document.οnmοusedοwn=x 单击鼠标触发事件
document.οndblclick=x 双击鼠标触发事件
defaultStatus window.status=defaultStatus; 将状态栏设置默认显示
function function xx(){...} 定义函数
isNumeric 判断是否是数字
innerHTML xx=对象.innerHTML 输入某对象标签中的html源代码
innerText divid.innerText=xx 将以div定位以id命名的对象值设为XX
location.reload(); 使本页刷新,target可等于一个刷新的网页
Math.random() 随机涵数,只能是0到1之间的数,如果要得到其它数,可以为*10,再取整
Math.floor(number) 将对象number转为整数,舍取所有小数
Math.min(1,2) 返回1,2哪个小
Math.max(1,2) 返回1,2哪个大
navigator.appName 返回当前浏览器名称
navigator.appVersion 返回当前浏览器版本号
navigator.appCodeName 返回当前浏览器代码名字
navigator.userAgent 返回当前浏览器用户代标志
onsubmit οnsubmit="return(xx())" 使用函数返回值
opener opener.document.对象 控制原打开窗体对象
prompt xx=window.prompt("提示信息","预定值"); 输入语句
parent parent.框架名.对象 控制框架页面
return return false 返回值
random 随机参数(0至1之间)
reset() form.reset(); 使form表单内的数据重置
split("") string.split("") 将string对象字符以逗号隔开
submit() form对象.submit() 使form对象提交数据
String对象的 charAt(x)对象 反回指定对象的第多少位的字母
lastIndexOf("string") 从右到左询找指定字符,没有返回-1
indexOf("string") 从左到右询找指定字符,没有返回-1
LowerCase() 将对象全部转为小写
UpperCase() 将对象全部转为大写
substring(0,5) string.substring(x,x) 返回对象中从0到5的字符
setTimeout("function",time) 设置一个超时对象
setInterval("function",time) 设置一个超时对象
toLocaleString() x.toLocaleString() 从x时间对象中获取时间,以字符串型式存在
typeof(变量名) 检查变量的类型,值有:String,Boolean,Object,Function,Underfined
window.event.button==1/2/3 鼠标键左键等于1右键等于2两个键一起按为3
window.screen.availWidth 返回当前屏幕宽度(空白空间)
window.screen.availHeight 返回当前屏幕高度(空白空间)
window.screen.width 返回当前屏幕宽度(分辨率值)
window.screen.height 返回当前屏幕高度(分辨率值)
window.document.body.offsetHeight; 返回当前网页高度
window.document.body.offsetWidth; 返回当前网页宽度
window.resizeTo(0,0) 将窗口设置宽高
window.moveTo(0,0) 将窗口移到某位置
window.focus() 使当前窗口获得焦点
window.scroll(x,y) 窗口滚动条坐标,y控制上下移动,须与函数配合
window.open() window.open("地址","名称","属性")
属性:toolbar(工具栏),location(地址栏),directions,status(状态栏),
menubar(菜单栏),scrollbar(滚动条),resizable(改变大小), width(宽),height(高),fullscreen(全 屏),scrollbars(全屏时无滚动条无参 数,channelmode(宽屏),left(打开窗口x坐标),top(打开窗口y坐标)
window.location = 'view-source:' + window.location.href 应用事件查看网页源代码;

a=new Date(); //创建a为一个新的时期对象
y=a.getYear(); //y的值为从对象a中获取年份值 两位数年份
y1=a.getFullYear(); //获取全年份数 四位数年份
m=a.getMonth(); //获取月份值
d=a.getDate(); //获取日期值
d1=a.getDay(); //获取当前星期值
h=a.getHours(); //获取当前小时数
m1=a.getMinutes(); //获取当前分钟数
s=a.getSeconds(); //获取当前秒钟数

对象.style.fontSize="文字大小";
单位:mm/cm/in英寸/pc帕/pt点/px象素/em文字高
1in=1.25cm
1pc=12pt
1pt=1.2px(800*600分辩率下)
文本字体属性:
fontSize大小
family字体
color颜色
fontStyle风格,取值为normal一般,italic斜体,oblique斜体且加粗
fontWeight加粗,取值为100到900不等,900最粗,light,normal,bold
letterSpacing间距,更改文字间距离,取值为,1pt,10px,1cm
textDecoration:文字修饰;取值,none不修饰,underline下划线,overline上划线
background:文字背景颜色,
backgroundImage:背景图片,取值为图片的插入路径

点击网页正文函数调用触发器:
1.onClick 当对象被点击
2.onLoad 当网页打开,只能书写在body中
3.onUnload 当网页关闭或离开时,只能书写在body中
4.onmouseover 当鼠标悬于其上时
5.onmouseout 当鼠标离开对象时
6.onmouseup 当鼠标松开
7.onmousedown 当鼠标按下键
8.onFocus 当对象获取焦点时
9.onSelect 当对象的文本被选中时
10.onChange 当对象的内容被改变
11.onBlur 当对象失去焦点
οnsubmit=return(ss())表单调用时返回的值
直线 border-bottom:1x solid black
虚线 border-bottom:1x dotted black
点划线 border-bottom:2x dashed black
双线 border-bottom:5x double black
槽状 border-bottom:1x groove black
脊状 border-bottom:1x ridge black

1.边缘高光glow(color=颜色,strength=亮光大小)

2.水平翻转fliph() 使对象水平翻转180度

3.垂直翻转flipv() 使对象垂直翻转180度

4.对象模糊blur(add=true/false direction=方向 strength=强度)
add指定是否按印象画派进行模糊direction模糊方向strength模糊强度
5.对象透明alpha(opaction=0-100,finishopacity=0-100,style=0/1/2/3)
opaction对象整体不透明值finishopacity当对象利用了渐透明时该项指定结束透明位置的不透明值style指定透明方式0为整体透明,1为线型透明,2为圆型透明,3为矩形透明
6.去除颜色chroma(color=颜色值)使对象中颜色与指定颜色相同区域透明
7.建立阴影dropshadow(color=阴影颜色,offx=水平向左偏离像素,offy=水平向下偏离像素)
8.去色gray()使对象呈灰度显示
9.负片效果invert()使对象呈底片效果
10.高光light()使对象呈黑色显示
11.遮盖mask(color=颜色)使整个对象以指定颜色进行蒙板一次
opacity 表透明度水平.0~100,0表全透明,100表完全不透明
finishopacity表想要设置的渐变透明效果.0~100.
style 表透明区的形状.0表统一形状.1表线形.2表放射形.3表长方形.
startx.starty表渐变透明效果的开始时X和Y坐标.
finishx,finishy渐变透明效果结束时x,y 的坐标.
add有来确定是否在模糊效果中使有原有目标.值为0,1.0表"否",1表"是".
direction设置模糊的方向.0度表垂直向上,45度为一个单位.默认值是向左270度.left,right,down,up.
strength 只能用整数来确定.代表有多少个像素的宽度将受到模糊影响.默认是5个.
color要透明的颜色.
offx,offy分别是x,y 方向阴影的偏移量.
positive指投影方式.0表透明像素生成阴影.1表只给出不透明像素生成阴影..
AddAmbient:加入包围的光源.
AddCone:加入锥形光源.
AddPoint加入点光源
Changcolor:改变光的颜色.
Changstrength:改变光源的强度.
Clear:清除所有的光源.
MoveLight:移动光源.
freq是波纹的频率,在指定在对象上一区需要产生多少个完事的波纹.
lightstrength可对于波纹增强光影的效果.显著0~100正整数,正弦波开始位置是0~360度.0表从0度开始,25表从90度开始.
strength表振幅大小.

hand
crosshair
text
wait
default
help
e-resize
ne-resize
n-resize
nw-resize
w-resize
s-resize
sw-resize
se-resize
auto

下载13个经典JS广告代码
[URL=event.clientX 返回最后一次点击鼠标X坐标值;
event.clientY 返回最后一次点击鼠标Y坐标值;
event.offsetX 返回当前鼠标悬停X坐标值
event.offsetY 返回当前鼠标悬停Y坐标值
document.write(document.lastModified) 网页最后一次更新时间
document.οndblclick=x 当双击鼠标产生事件
document.οnmοusedοwn=x 单击鼠标键产生事件
document.body.scrollTop; 返回和设置当前竖向滚动条的坐标值,须与函数配合,
document.body.scrollLeft; 返回和设置当前横向滚动务的坐标值,须与函数配合,
document.title document.title="message"; 当前窗口的标题栏文字
document.bgcolor document.bgcolor="颜色值"; 改变窗口背景颜色
document.Fgcolor document.Fgcolor="颜色值"; 改变正文颜色
document.linkcolor document.linkcolor="颜色值"; 改变超联接颜色
document.alinkcolor document.alinkcolor="颜色值"; 改变正点击联接的颜色
document.VlinkColor document.VlinkColor="颜色值"; 改变已访问联接的颜色
document.forms.length 返回当前页form表单数
document.anchors.length 返回当前页锚的数量
document.links.length 返回当前页联接的数量
document.οnmοusedοwn=x 单击鼠标触发事件
document.οndblclick=x 双击鼠标触发事件
defaultStatus window.status=defaultStatus; 将状态栏设置默认显示
function function xx(){...} 定义函数
isNumeric 判断是否是数字
innerHTML xx=对象.innerHTML 输入某对象标签中的html源代码
innerText divid.innerText=xx 将以div定位以id命名的对象值设为XX
location.reload(); 使本页刷新,target可等于一个刷新的网页
Math.random() 随机涵数,只能是0到1之间的数,如果要得到其它数,可以为*10,再取整
Math.floor(number) 将对象number转为整数,舍取所有小数
Math.min(1,2) 返回1,2哪个小
Math.max(1,2) 返回1,2哪个大
navigator.appName 返回当前浏览器名称
navigator.appVersion 返回当前浏览器版本号
navigator.appCodeName 返回当前浏览器代码名字
navigator.userAgent 返回当前浏览器用户代标志
onsubmit οnsubmit="return(xx())" 使用函数返回值
opener opener.document.对象 控制原打开窗体对象
prompt xx=window.prompt("提示信息","预定值"); 输入语句
parent parent.框架名.对象 控制框架页面
return return false 返回值
random 随机参数(0至1之间)
reset() form.reset(); 使form表单内的数据重置
split("") string.split("") 将string对象字符以逗号隔开
submit() form对象.submit() 使form对象提交数据
String对象的 charAt(x)对象 反回指定对象的第多少位的字母
lastIndexOf("string") 从右到左询找指定字符,没有返回-1
indexOf("string") 从左到右询找指定字符,没有返回-1
LowerCase() 将对象全部转为小写
UpperCase() 将对象全部转为大写
substring(0,5) string.substring(x,x) 返回对象中从0到5的字符
setTimeout("function",time) 设置一个超时对象
setInterval("function",time) 设置一个超时对象
toLocaleString() x.toLocaleString() 从x时间对象中获取时间,以字符串型式存在
typeof(变量名) 检查变量的类型,值有:String,Boolean,Object,Function,Underfined
window.event.button==1/2/3 鼠标键左键等于1右键等于2两个键一起按为3
window.screen.availWidth 返回当前屏幕宽度(空白空间)
window.screen.availHeight 返回当前屏幕高度(空白空间)
window.screen.width 返回当前屏幕宽度(分辨率值)
window.screen.height 返回当前屏幕高度(分辨率值)
window.document.body.offsetHeight; 返回当前网页高度
window.document.body.offsetWidth; 返回当前网页宽度
window.resizeTo(0,0) 将窗口设置宽高
window.moveTo(0,0) 将窗口移到某位置
window.focus() 使当前窗口获得焦点
window.scroll(x,y) 窗口滚动条坐标,y控制上下移动,须与函数配合
window.open() window.open("地址","名称","属性")
属性:toolbar(工具栏),location(地址栏),directions,status(状态栏),
menubar(菜单栏),scrollbar(滚动条),resizable(改变大小), width(宽),height(高),fullscreen(全 屏),scrollbars(全屏时无滚动条无参 数,channelmode(宽屏),left(打开窗口x坐标),top(打开窗口y坐标)
window.location = 'view-source:' + window.location.href 应用事件查看网页源代码;

a=new Date(); //创建a为一个新的时期对象
y=a.getYear(); //y的值为从对象a中获取年份值 两位数年份
y1=a.getFullYear(); //获取全年份数 四位数年份
m=a.getMonth(); //获取月份值
d=a.getDate(); //获取日期值
d1=a.getDay(); //获取当前星期值
h=a.getHours(); //获取当前小时数
m1=a.getMinutes(); //获取当前分钟数
s=a.getSeconds(); //获取当前秒钟数

对象.style.fontSize="文字大小";
单位:mm/cm/in英寸/pc帕/pt点/px象素/em文字高
1in=1.25cm
1pc=12pt
1pt=1.2px(800*600分辩率下)
文本字体属性:
fontSize大小
family字体
color颜色
fontStyle风格,取值为normal一般,italic斜体,oblique斜体且加粗
fontWeight加粗,取值为100到900不等,900最粗,light,normal,bold
letterSpacing间距,更改文字间距离,取值为,1pt,10px,1cm
textDecoration:文字修饰;取值,none不修饰,underline下划线,overline上划线
background:文字背景颜色,
backgroundImage:背景图片,取值为图片的插入路径

点击网页正文函数调用触发器:
1.onClick 当对象被点击
2.onLoad 当网页打开,只能书写在body中
3.onUnload 当网页关闭或离开时,只能书写在body中
4.onmouseover 当鼠标悬于其上时
5.onmouseout 当鼠标离开对象时
6.onmouseup 当鼠标松开
7.onmousedown 当鼠标按下键
8.onFocus 当对象获取焦点时
9.onSelect 当对象的文本被选中时
10.onChange 当对象的内容被改变
11.onBlur 当对象失去焦点
οnsubmit=return(ss())表单调用时返回的值
直线 border-bottom:1x solid black
虚线 border-bottom:1x dotted black
点划线 border-bottom:2x dashed black
双线 border-bottom:5x double black
槽状 border-bottom:1x groove black
脊状 border-bottom:1x ridge black

1.边缘高光glow(color=颜色,strength=亮光大小)

2.水平翻转fliph() 使对象水平翻转180度

3.垂直翻转flipv() 使对象垂直翻转180度

4.对象模糊blur(add=true/false direction=方向 strength=强度)
add指定是否按印象画派进行模糊direction模糊方向strength模糊强度
5.对象透明alpha(opaction=0-100,finishopacity=0-100,style=0/1/2/3)
opaction对象整体不透明值finishopacity当对象利用了渐透明时该项指定结束透明位置的不透明值style指定透明方式0为整体透明,1为线型透明,2为圆型透明,3为矩形透明
6.去除颜色chroma(color=颜色值)使对象中颜色与指定颜色相同区域透明
7.建立阴影dropshadow(color=阴影颜色,offx=水平向左偏离像素,offy=水平向下偏离像素)
8.去色gray()使对象呈灰度显示
9.负片效果invert()使对象呈底片效果
10.高光light()使对象呈黑色显示
11.遮盖mask(color=颜色)使整个对象以指定颜色进行蒙板一次
opacity 表透明度水平.0~100,0表全透明,100表完全不透明
finishopacity表想要设置的渐变透明效果.0~100.
style 表透明区的形状.0表统一形状.1表线形.2表放射形.3表长方形.
startx.starty表渐变透明效果的开始时X和Y坐标.
finishx,finishy渐变透明效果结束时x,y 的坐标.
add有来确定是否在模糊效果中使有原有目标.值为0,1.0表"否",1表"是".
direction设置模糊的方向.0度表垂直向上,45度为一个单位.默认值是向左270度.left,right,down,up.
strength 只能用整数来确定.代表有多少个像素的宽度将受到模糊影响.默认是5个.
color要透明的颜色.
offx,offy分别是x,y 方向阴影的偏移量.
positive指投影方式.0表透明像素生成阴影.1表只给出不透明像素生成阴影..
AddAmbient:加入包围的光源.
AddCone:加入锥形光源.
AddPoint加入点光源
Changcolor:改变光的颜色.
Changstrength:改变光源的强度.
Clear:清除所有的光源.
MoveLight:移动光源.
freq是波纹的频率,在指定在对象上一区需要产生多少个完事的波纹.
lightstrength可对于波纹增强光影的效果.显著0~100正整数,正弦波开始位置是0~360度.0表从0度开始,25表从90度开始.
strength表振幅大小.

hand
crosshair
text
wait
default
help
e-resize
ne-resize
n-resize
nw-resize
w-resize
s-resize
sw-resize
se-resize
auto
--------------

1.取消按钮按下时的虚线框   
  在input里添加属性值 hideFocus 或者 HideFocus=true   
  
2.只读文本框内容   
在input里添加属性值 readonly   
  
3.防止退后清空的TEXT文档(可把style内容做做为类引用)   
  <INPUT style=behavior:url(#default#savehistory); type=text id=oPersistInput>   
  
4.ENTER键可以让光标移到下一个输入框   
  <input οnkeydοwn="if(event.keyCode==13)event.keyCode=9" >   
  
5.只能为中文(有闪动)   
  <input οnkeyup="value=value.replace(/[ -~]/g,'')" οnkeydοwn="if(event.keyCode==13)event.keyCode=9">   
  
6.只能为数字(有闪动)   
  <input οnkeyup="value=value.replace(/[^\d]/g,'') "onbeforepaste= "clipboardData.setData(’text’,clipboardData.getData(’text’).replace(/[^\d]/g,’’))">   
  
7.只能为数字(无闪动)   
  <input οnkeydοwn="if(event.keyCode==13) event.keyCode=9" onKeyPress="if ((event.keyCode<48 || event.keyCode>57)) event.returnValue=false">   
  
8.只能输入英文和数字(有闪动)   
  <input οnkeyup="value=value.replace(/[\W]/g,’’)" onbeforepaste= "clipboardData.setData(’text’,clipboardData.getData(’text’).replace(/[^\d]/g,’’))">   
  
9.屏蔽输入法   
  <input type="text" name="url" οnkeydοwn="if(event.keyCode==13)event.keyCode=9">   
  
10. 只能输入 数字,小数点,减号(-) 字符(无闪动)   
  <input onKeyPress="if (event.keyCode!=46 && event.keyCode!= 45 && (event.keyCode<48 || event.keyCode>57)) event.returnValue=false">   
  
11. 只能输入两位小数,三位小数(有闪动)   
  <input maxlength=9 οnkeyup="if(value.match(/^\d{3}$/))value= value.replace(value,parseInt(value/10)) ;value=value.replace(/\.\d*\./g,’.’)" onKeyPress="if((event.keyCode<48 || event.keyCode>57) && event.keyCode!=46 && event.keyCode!=45 || value.match(/^\d{3}$/) || /\.\d{3}$/.test(value)) {event.returnValue=false}" id=text_kfxe name=text_kfxe>   
  
  
------------------------------------------------------------------------   
<input type="text" name="input1" value="中国">   
  
怎样使input中的内容为只读,也就是说不让用户更改里面的内容。   
<input type="text" name="input1" value="中国" οnfοcus=this.blur()>   
<input type="text" name="input1" value="中国" readonly>   
<input type="text" name="input1" value="中国" disabled>   
最好不要用disabled,不然就无法取出里面的值了.   
<input type="text" name="input1" value="中国" readonly="true">   
<input type="text" name="input1" value="中国" readonly >

转载于:https://www.cnblogs.com/newnet/archive/2012/03/23/2413099.html

BS前台能力迅速提高相关推荐

  1. 积极向上,努力工作,提高能力,提高战斗力,保持热情,保持创业热情。

    积极向上,努力工作,提高能力,提高战斗力,保持热情,保持创业热情. 转载于:https://www.cnblogs.com/iosDevZhong/p/4395230.html

  2. 论单片机IO引脚驱动能力的提高

    单片机IO引脚驱动能力的提高 早期的51单片机,驱动能力很低.P1.P2和P3口只能驱动3个LSTTL输入端,P0口可驱动8个.如果想要驱动更多的器件,就要用到"总线驱动芯片".经 ...

  3. 怎样提高学生计算机应用能力,如何提高中职学生计算机应用能力

    摘要:随着计算机技术的飞速发展和计算机应用的日益普及,对我们中职学生的要求越来越高,信息化技术水平对职校的学生的要求也越来越高,用人单位对毕业生的计算机应用能力要求也不断提升,这就对非计算机专业的计算 ...

  4. 计算机专业大创要求,“大创项目”推动计算机专业学生创新实践能力的提高

    2016年第1期 总第172期 27 创新创业就业 计算机科学与技术专业是自1980年各高等院校成立计算机专业以来的老牌专业.目前,绝大多数高校都设置计算机或与其相近的专业,每年有大批计算机科学专业的 ...

  5. (HR职场)什么是计划能力?如何提高计划能力?

    不论是学习还是工作,光靠努力是不行的,还得有计划,有周密的部署,懂得按计划做事情的人,不仅可以高效率地完成工作,还能在枯燥的工作中寻找到乐趣.这就是做计划的意义和必要性.当然光有计划也不行,还得有执行 ...

  6. 东芝新半导体公司将强化提出解决方案的能力并提高研发效率

    东京--(美国商业资讯)--东芝电子元件及存储装置株式会社(TDSC)今日宣布将旗下东芝微电子株式会社(TOSMEC)和东芝离散半导体技术株式会社(TDIT)两个子公司合并为一家新公司,即东芝电子元件 ...

  7. 单片机IO引脚驱动能力的提高

    早期的51单片机,驱动能力很低.P1.P2和P3口只能驱动3个LSTTL输入端,P0口可驱动8个.如果想要驱动更多的器件,就要用到"总线驱动芯片".经常用的就是74LS244(单向 ...

  8. 最小环(【CCF】NOI Online能力测试 提高组第三题)

    [题目描述] 给定一个长度为 n 的正整数序列 ai,下标从 1 开始编号.我们将该序列视为一个首尾相邻的环,更具体地,对于下标为 i,j(i ≤ j) 的两个数 ai,aj,它们的距离为 min(j ...

  9. 冒泡排序(【CCF】NOI Online能力测试 提高组第二题)

    [题目描述] 给定一个 1 - n 的排列 pi,接下来有 m 次操作,操作共两种: 1.交换操作:给定 x,将当前排列中的第 x 个数与第 x+1 个数交换位置. 2.询问操作:给定 k,请你求出当 ...

最新文章

  1. 交换三个整数的值,并输出
  2. AsyncTask进度条加载网站数据到ListView
  3. HDOJ 1253 HDU 1253 胜利大逃亡 ACM 1253 IN HDU
  4. FTP中传输模式:BIN与ASC的差别
  5. 使用第三方《UITableView+FDTemplateLayoutCell》自动计算UITableViewCell高度(Masonry约束)...
  6. 让Windows Live Messenger支持多账户登录
  7. python len函数_你需要了解的最重要的Python概念
  8. 工作中git常用命令
  9. hadoop2.6.0的eclipse插件编译和设置
  10. spring nature
  11. 数字集成电路版图设计(二)——Cadence IC简单的反相器版图设计
  12. 计算机音乐谱策马奔腾,策马奔腾简谱
  13. Windows在后台自动启动cmd命令
  14. 计算机服务器组装,一台家用虚拟化测试服务器组装
  15. self paced learning(自步学习)
  16. 计算机英语构词法,【计算机专业论文】计算机专业英语的构词方法(共2969字)
  17. 【python趣味小代码】为你女(男)神打造专属素描照,hhhhhh
  18. 美图手机显示无服务器,美图手机云服务器
  19. CockroachDB简介
  20. 新版付费塔罗牌测算源码 (附带搭建教程)

热门文章

  1. uuid重复_0519-如何解决Cloudera Manager主机页面出现重复主机异常
  2. java count 在哪一类里_count 是java关键字吗
  3. 群里又会python的吗_自从会了Python在群里斗图就没输过,Python批量下载表情包!...
  4. matlab2012b函数问题,MATLAB版本(2012b 64bit)在尝试调用svmtrain函数时报错
  5. log4j 按天打印到文件夹_log4j日志打印到前一天的日志文件中
  6. 构建新模式java_Nacos 1.3.0 来了,基于全新内核构建!
  7. mysql typedefinition_深入浅出Mysql——基础篇
  8. mysql创建gbk库_MYSQL创建utf-8和GBK格式数据库
  9. flutter 禁止冒泡_【Flutter】Switch开关组件
  10. php t double arrow,php – 语法错误,意外T_DOUBLE_ARROW