亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 開發 > JS > 正文

網頁教學網整理的JS技巧代碼

2024-09-06 12:40:52
字體:
來源:轉載
供稿:網友

相關文章:網頁設計整理的javascript的技巧代碼

//過濾數字

<input type=text onkeypress="return event.keycode>=48&&event.keycode<=57||(this.value.indexof('.')<0?event.keycode==46:false)" onpaste="return !clipboarddata.getdata('text').match(//d/)" ondragenter="return false">

//特殊用途

<input type=button value=導入收藏夾 onclick="window.external.importexportfavorites(true,'http://localhost');">
<input type=button value=導出收藏夾 onclick="window.external.importexportfavorites(false,'http://localhost');">
<input type=button value=整理收藏夾 onclick="window.external.showbrowserui('organizefavorites', null)">
<input type=button value=語言設置   onclick="window.external.showbrowserui('languagedialog', null)">
<input type=button value=加入收藏夾 onclick="window.external.addfavorite('http://www.google.com/', 'google')">
<input type=button value=加入到頻道 onclick="window.external.addchannel('http://www.google.com/')">
<input type=button value=加入到頻道 onclick="window.external.showbrowserui('privacysettings',null)">

//不緩存

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache, must-revalidate">
<meta http-equiv="expires" content="0">

//正則匹配

匹配中文字符的正則表達式: [/u4e00-/u9fa5]
匹配雙字節字符(包括漢字在內):[^/x00-/xff]
匹配空行的正則表達式:/n[/s| ]*/r
匹配html標記的正則表達式:/<(.*)>.*<///1>|<(.*) //>/ 
匹配首尾空格的正則表達式:(^/s*)|(/s*$)(像vbscript那樣的trim函數)
匹配email地址的正則表達式:/w+([-+.]/w+)*@/w+([-.]/w+)*/./w+([-.]/w+)*
匹配網址url的正則表達式:http://([/w-]+/.)+[/w-]+(/[/w- ./?%&=]*)?

以下是例子:

利用正則表達式限制網頁表單里的文本框輸入內容:

用正則表達式限制只能輸入中文:onkeyup="value=value.replace(/[^/u4e00-/u9fa5]/g,'')" onbeforepaste="clipboarddata.setdata('text',clipboarddata.getdata('text').replace(/[^/u4e00-/u9fa5]/g,''))"
1.用正則表達式限制只能輸入全角字符: onkeyup="value=value.replace(/[^/uff00-/uffff]/g,'')" onbeforepaste="clipboarddata.setdata('text',clipboarddata.getdata('text').replace(/[^/uff00-/uffff]/g,''))"
2.用正則表達式限制只能輸入數字:onkeyup="value=value.replace(/[^/d]/g,'') "onbeforepaste="clipboarddata.setdata('text',clipboarddata.getdata('text').replace(/[^/d]/g,''))"
3.用正則表達式限制只能輸入數字和英文:onkeyup="value=value.replace(/[/w]/g,'') "onbeforepaste="clipboarddata.setdata('text',clipboarddata.getdata('text').replace(/[^/d]/g,''))"

//消除圖像工具欄

<img src="mypicture.jpg" height="100px" width="100px" galleryimg="false"> 
or
<head>
<meta http-equiv="imagetoolbar" content="no">
</head>

//無提示關閉

function close()
{
var ua=navigator.useragent
var ie=navigator.appname=="microsoft internet explorer"?true:false
if(ie)
{
      var ieversion=parsefloat(ua.substring(ua.indexof("msie ")+5,ua.indexof(";",ua.indexof("msie "))))
  if(ieversion< 5.5)
  {
   var str  = '<object id=notipclose classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">'
       str += '<param name="command" value="close"></object>';
       document.body.insertadjacenthtml("beforeend", str);
       document.all.notipclose.click();
  }
      else
  {
       window.opener =null;
       window.close();
      }
   }
else
{
  window.close()
   }
}

//取得控件得絕對位置(1)

<script language="javascript"> 
function getoffset(e)

 var t=e.offsettop; 
 var l=e.offsetleft; 
 while(e=e.offsetparent)
 { 
  t+=e.offsettop; 
  l+=e.offsetleft; 
 } 
 var rec = new array(1);
 rec[0]  = t;
 rec[1] = l;
 return rec

</script>

//獲得控件的絕對位置(2)

orect = obj.getboundingclientrect();
orect.left
orect.

//最小化,最大化,關閉

<object id=min classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"> 
<param name="command" value="minimize"></object> 
<object id=max classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"> 
<param name="command" value="maximize"></object> 
<object id=close classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"> 
<param name="command" value="close"></object> 
<input type=button value=最小化 onclick=min.click()> 
<input type=button value=最大化 onclick=max.click()> 
<input type=button value=關閉 onclick=close.click()> 

//光標停在文字最后

<script language="javascript">
function cc()
{
 var e = event.srcelement;
 var r =e.createtextrange();
 r.movestart('character',e.value.length);
 r.collapse(true);
 r.select();
}
</script>
<input type=text name=text1 value="123" onfocus="cc()">

//頁面進入和退出的特效


進入頁面<meta http-equiv="page-enter" content="revealtrans(duration=x, transition=y)">
推出頁面<meta http-equiv="page-exit" content="revealtrans(duration=x, transition=y)"> 
這個是頁面被載入和調出時的一些特效。duration表示特效的持續時間,以秒為單位。transition表示使
用哪種特效,取值為1-23:
  0 矩形縮小 
  1 矩形擴大 
  2 圓形縮小
  3 圓形擴大 
  4 下到上刷新 
  5 上到下刷新
  6 左到右刷新 
  7 右到左刷新 
  8 豎百葉窗
  9 橫百葉窗 
  10 錯位橫百葉窗 
  11 錯位豎百葉窗
  12 點擴散 
  13 左右到中間刷新 
  14 中間到左右刷新
  15 中間到上下
  16 上下到中間 
  17 右下到左上
  18 右上到左下 
  19 左上到右下 
  20 左下到右上
  21 橫條 
  22 豎條 
  23 

//網頁是否被檢索

<meta name="robots" content="屬性值">
  其中屬性值有以下一些:
  屬性值為"all": 文件將被檢索,且頁上鏈接可被查詢;
  屬性值為"none": 文件不被檢索,而且不查詢頁上的鏈接;
  屬性值為"index": 文件將被檢索;
  屬性值為"follow": 查詢頁上的鏈接;
  屬性值為"noindex": 文件不檢索,但可被查詢鏈接;
  屬性值為"nofollow": 

//打印分頁

<p  style="page-break-after:always">page1</p>  
<p  style="page-break-after:always">page2</p>  

//設置打印

 
<object id="factory" style="display:none" viewastext
  classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
  codebase="http://www.meadroid.com/scriptx/scriptx.cab#version=5,60,0,360"
></object>
<input type=button value=頁面設置 onclick="factory.printing.pagesetup()">
<input type=button value=打印預覽 onclick="factory.printing.preview()">
 
<script language=javascript>
function window.onload()
{
   // -- advanced features
   factory.printing.setmarginmeasure(2) // measure margins in inches
   factory.printing.setpagerange(false, 1, 3) // need pages from 1 to 3
   factory.printing.printer = "hp deskjet 870c"
   factory.printing.copies = 2
   factory.printing.collate = true
   factory.printing.papersize = "a4"
   factory.printing.papersource = "manual feed"
   // -- basic features
   factory.printing.header = "居左顯示&b居中顯示&b居右顯示頁碼,第&p頁/共&p頁"
   factory.printing.footer = "(自定義頁腳)"
   factory.printing.portrait = false
   factory.printing.leftmargin = 0.75
   factory.printing.topmargin = 1.5
   factory.printing.rightmargin = 0.75
   factory.printing.bottommargin = 1.5
}
function print(frame) {
  factory.printing.print(true, frame) // print with prompt
}
</script>
<input type=button value="打印本頁" onclick="factory.printing.print(false)">
<input type=button value="頁面設置" onclick="factory.printing.pagesetup()">
<input type=button value="打印預覽" onclick="factory.printing.preview()"><br>
<a href="http://www.meadroid.com/scriptx/docs/printdoc.htm?static"  target=_blank>具體使用手冊,更多信息,點這里</a>

//自帶的打印預覽

webbrowser.execwb(1,1) 打開 
web.execwb(2,1) 關閉現在所有的ie窗口,并打開一個新窗口 
web.execwb(4,1) 保存網頁 
web.execwb(6,1) 打印 
web.execwb(7,1) 打印預覽 
web.execwb(8,1) 打印頁面設置 
web.execwb(10,1) 查看頁面屬性 
web.execwb(15,1) 好像是撤銷,有待確認 
web.execwb(17,1) 全選 
web.execwb(22,1) 刷新 
web.execwb(45,1) 關閉窗體無提示 
<style media=print> 
.noprint{display:none;}<!--用本樣式在打印時隱藏非打印項目--> 
.pagenext{page-break-after: always;}<!--控制分頁--> 
</style> 
<object  id="webbrowser"  width=0  height=0  classid="clsid:8856f961-340a-11d0-a96b-00c04fd705a2">    
</object>
<center class="noprint" >
<input type=button value=打印 onclick=document.all.webbrowser.execwb(6,1)> 
<input type=button value=直接打印 onclick=document.all.webbrowser.execwb(6,6)> 
<input type=button value=頁面設置 onclick=document.all.webbrowser.execwb(8,1)> 
</p> 
<p> <input type=button value=打印預覽 onclick=document.all.webbrowser.execwb(7,1)> 
</center>

//去掉打印時的頁眉頁腳

 
<script  language="javascript">  
var hkey_root,hkey_path,hkey_key;
hkey_root="hkey_current_user";
hkey_path="//software//microsoft//internet explorer//pagesetup//";
//設置網頁打印的頁眉頁腳為空
function pagesetup_null()
{
 try
 {
         var wsh=new activexobject("wscript.shell");
  hkey_key="header";
  wsh.regwrite(hkey_root+hkey_path+hkey_key,"");
  hkey_key="footer";
  wsh.regwrite(hkey_root+hkey_path+hkey_key,"");
 }
 catch(e){}
}
//設置網頁打印的頁眉頁腳為默認值
function  pagesetup_default()
{  
 try
 {
  var wsh=new activexobject("wscript.shell");
  hkey_key="header";
  wsh.regwrite(hkey_root+hkey_path+hkey_key,"&w&b頁碼,&p/&p");
  hkey_key="footer";
  wsh.regwrite(hkey_root+hkey_path+hkey_key,"&u&b&d");
 }
 catch(e){}
}
</script>
<input type="button" value="清空頁碼" onclick=pagesetup_null()>
<input type="button" value="恢復頁碼" onclick=pagesetup_default()>

//瀏覽器驗證

function checkbrowser()

   this.ver=navigator.appversion 
   this.dom=document.getelementbyid?1:0 
   this.ie6=(this.ver.indexof("msie 6")>-1 && this.dom)?1:0; 
   this.ie5=(this.ver.indexof("msie 5")>-1 && this.dom)?1:0; 
   this.ie4=(document.all && !this.dom)?1:0; 
   this.ns5=(this.dom && parseint(this.ver) >= 5) ?1:0; 
   this.ns4=(document.layers && !this.dom)?1:0; 
   this.mac=(this.ver.indexof('mac') > -1) ?1:0; 
   this.ope=(navigator.useragent.indexof('opera')>-1); 
   this.ie=(this.ie6 || this.ie5 || this.ie4) 
   this.ns=(this.ns4 || this.ns5) 
   this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns5 || this.ns4 || this.mac || this.ope) 
   this.nbw=(!this.bw) 
   return this;
}

//計算內容寬和高

<script  language="javascript">  
function  test(obj)  
{  
       var  range  =  obj.createtextrange();  
       alert("內容區寬度:  "  +  range.boundingwidth    
                                                 +  "px/r/n內容區高度:  "  +  range.boundingheight  +  "px");  
             
}  
</script>  
<body>  
<textarea id="txt" height="150">sdf</textarea><input  type="button"  value="計算內容寬度"  onclick="test(txt)">  
</body>

//無模式的提示框

function modelessalert(msg)
{
   window.showmodelessdialog("javascript:alert(/""+escape(msg)+"/");window.close();","","status:no;resizable:no;help:no;dialogheight:height:30px;dialogheight:40px;");
}

//屏蔽按鍵

<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=gb2312">
  <noscript><meta http-equiv="refresh" content="0;url=about:noscript"></noscript>
  <title>屏蔽鼠標右鍵、ctrl+n、shift+f10、alt+f4、f11、f5刷新、退格鍵</title>
</head>
<body>
<script language="javascript"><!--
  //屏蔽鼠標右鍵、ctrl+n、shift+f10、f11、f5刷新、退格鍵
  //author: meizz(梅花雨) 2002-6-18
function document.oncontextmenu(){event.returnvalue=false;}//屏蔽鼠標右鍵
function window.onhelp(){return false} //屏蔽f1幫助
function document.onkeydown()
{
  if ((window.event.altkey)&&
      ((window.event.keycode==37)||   //屏蔽 alt+ 方向鍵 ←
       (window.event.keycode==39)))   //屏蔽 alt+ 方向鍵 →
  {
     alert("不準你使用alt+方向鍵前進或后退網頁!");
     event.returnvalue=false;
  }
     /* 注:這還不是真正地屏蔽 alt+ 方向鍵,
     因為 alt+ 方向鍵彈出警告框時,按住 alt 鍵不放,
     用鼠標點掉警告框,這種屏蔽方法就失效了。以后若
     有哪位高手有真正屏蔽 alt 鍵的方法,請告知。*/
  if ((event.keycode==8)  ||                 //屏蔽退格刪除鍵
      (event.keycode==116)||                 //屏蔽 f5 刷新鍵
      (event.ctrlkey && event.keycode==82)){ //ctrl + r
     event.keycode=0;
     event.returnvalue=false;
     }
  if (event.keycode==122){event.keycode=0;event.returnvalue=false;}  //屏蔽f11
  if (event.ctrlkey && event.keycode==78) event.returnvalue=false;   //屏蔽 ctrl+n
  if (event.shiftkey && event.keycode==121)event.returnvalue=false;  //屏蔽 shift+f10
  if (window.event.srcelement.tagname == "a" && window.event.shiftkey) 
      window.event.returnvalue = false;             //屏蔽 shift 加鼠標左鍵新開一網頁
  if ((window.event.altkey)&&(window.event.keycode==115))             //屏蔽alt+f4
  {
      window.showmodelessdialog("about:blank","","dialogwidth:1px;dialogheight:1px");
      return false;
  }
}
</script>
屏蔽鼠標右鍵、ctrl+n、shift+f10、alt+f4、f11、f5刷新、退格鍵
</body>
</html>

//屏蔽打印

<style>
@media print{
* {display:none}
}
</style>

//移動的圖層,拖動

1.

<span style='position:absolute;width:200;height:200;background:red' onmousedown=mousedown(this) onmousemove=mousemove() onmouseup=mouseup()>meizz</span>
<script language=javascript>
var obj;
function mousedown(obj)
{
  obj=obj;
  obj.setcapture();
  obj.l=event.x-obj.style.pixelleft;
  obj.t=event.y-obj.style.pixeltop;
}
function mousemove()
{
  if(obj!=null)
  {
    obj.style.left = event.x-obj.l;
    obj.style.top = event.y-obj.t;
  }
}
function mouseup()
{
  if(obj!=null)
  {
    obj.releasecapture();
    obj=null;
  }
}
</script>

2.
<div id="mydiv" src="logo.gif" ondrag="dodrag();" onmouseover="this.style.cursor='hand'" style="position:absolute;left=100;top=100;" onmousedown="domousedown();">
<a href="#" onclick="return false"><h1>wlecome</h1></a>
</div>
<script language="javascript" type="text/javascript">
var orgmousex;
var orgmousey;
var orgobjx;
var orgobjy;
function dodrag()
{
var myobject=document.all.mydiv;
var x=event.clientx;
var y=event.clienty;
myobject.style.left=x-(orgmousex-orgobjx);
myobject.style.top=y-(orgmousey-orgobjy);
 
}
function domousedown()
{
orgmousex=event.clientx;
orgmousey=event.clienty;
orgobjx=parseint(document.all.mydiv.style.left);
orgobjy=parseint(document.all.mydiv.style.top);
}
</script>


//文檔狀態改變

<iframe src="a.html" id="f" name="f" scrolling="no" frameborder=0 marginwidth=0 marginheight=0></iframe>
<script>
var doc=window.frames["f"].document;
function s(){
 if (doc.readystate=="complete"){
  document.all.f.style.height=doc.body.scrollheight
  document.all.f.style.width=doc.body.scrollwidth
 }
}
doc.onreadystatechange=s
</script>


//刷新后不變的文本框

<html>
<head>
<meta name="save" content="history">
<style>
   .shistory {behavior:url(#default#savehistory);}
</style>
</head>
<body>
<input class=shistory type=text id=opersistinput>
</body>
</html>


//訪問剪貼板

(1)拖拽訪問

event.datatransfer.setdata("url", oimage.src);
simageurl = event.datatransfer.getdata("url");

(2)普通訪問

window.clipboarddata.setdata("text",osource.innertext);
window.clipboarddata.getdata("text");

//操作cookie

function setcookie(sname, svalue)
{
document.cookie = sname + "=" + escape(svalue) + "; ";
}
function getcookie(sname)
{
var acookie = document.cookie.split("; ");
for (var i=0; i < acookie.length; i++)
{
  
  var acrumb = acookie[i].split("=");
  if (sname == acrumb[0]) 
  return unescape(acrumb[1]);
}
 
}
function delcookie(sname)
{
document.cookie = sname + "=" + escape(svalue) + "; expires=fri, 31 dec 1999 23:59:59 gmt;";
}

//settimeout增加參數

<script>
var _st = window.settimeout;
window.settimeout = function(fref, mdelay) {
 if(typeof fref == 'function'){
  var argu = array.prototype.slice.call(arguments,2);
  var f = (function(){ fref.apply(null, argu); });
  return _st(f, mdelay);
 }
 return _st(fref,mdelay);
}
function test(x){
 alert(x);
}
window.settimeout(test,1000,'fason');
</script>

//自定義的apply,call

function.prototype.apply = function (obj, argu) {
if (obj) obj.constructor.prototype._caller = this; 
var argus = new array();
for (var i=0;i<argu.length;i++)
  argus[i] = "argu[" + i + "]";
var r;
eval("r = " + (obj ? ("obj._caller(" + argus.join(",") + ");") : ("this(" + argus.join(",") + ");")));
return r;
};
function.prototype.call = function (obj) {
var argu = new array();
for (var i=1;i<arguments.length;i++)
  argu[i-1] = arguments[i];
return this.apply(obj, argu);
};

//下載文件

function downurl(strremoteurl,strlocalurl)
{
try
{
  var xmlhttp=new activexobject("microsoft.xmlhttp");
  xmlhttp.open("get",strremoteurl,false);
  xmlhttp.send();
  var adodbstream=new activexobject("adodb.stream");
  adodbstream.type=1;//1=adtypebinary
  adodbstream.open();
  adodbstream.write(xmlhttp.responsebody);
  adodbstream.savetofile(strlocalurl,2);
  adodbstream.close();
  adodbstream=null;
  xmlhttp=null;
  
}
catch(e)
{
  window.confirm("下載url出錯!");
}
//window.confirm("下載完成.");
}

//檢驗連接是否有效

function getxml(url) 
{
var xmlhttp = new activexobject("microsoft.xmlhttp");
xmlhttp.open("get",url, false); 
try

  xmlhttp.send();
}
catch(e){}
finally 
{
  var result = xmlhttp.responsetext;
  if(result) 
  {
   if(xmlhttp.status==200)
   {
    return(true);
   }
   else 
   {
    return(false);
   }
  }
  else 
  {
   return(false);
  }
}
}

//post代替form

<script language="vbscript">
function urlencoding(vstrin)
    strreturn = ""
    for i = 1 to len(vstrin)
        thischr = mid(vstrin,i,1)
        if abs(asc(thischr)) < &hff then
            strreturn = strreturn & thischr
        else
            innercode = asc(thischr)
            if innercode < 0 then
                innercode = innercode + &h10000
            end if
            hight8 = (innercode  and &hff00)/ &hff
            low8 = innercode and &hff
            strreturn = strreturn & "%" & hex(hight8) &  "%" & hex(low8)
        end if
    next
    urlencoding = strreturn
end function
function bytes2bstr(vin)
    strreturn = ""
    for i = 1 to lenb(vin)
        thischarcode = ascb(midb(vin,i,1))
        if thischarcode < &h80 then
            strreturn = strreturn & chr(thischarcode)
        else
            nextcharcode = ascb(midb(vin,i+1,1))
            strreturn = strreturn & chr(clng(thischarcode) * &h100 + cint(nextcharcode))
            i = i + 1
        end if
    next
    bytes2bstr = strreturn
end function
dim stra,oreq
stra = urlencoding("submit1=submit&text1=中文")
set oreq = createobject("msxml2.xmlhttp")
oreq.open "post","http://servername/vdir/tstresult.asp",false
oreq.setrequestheader "content-length",len(stra)
oreq.setrequestheader "content-type","application/x-www-form-urlencoded"
oreq.send stra
msgbox bytes2bstr(oreq.responsebody)
</script>

//readystate是xmlhttp返回數據的進度,0=載入中,1=未初始化,2=已載入,3=運行中,4=完成

//組件是否安裝

iscomponentinstalled("{6b053a4b-a7ec-4d3d-4567-b8ff8a1a5739}", "componentid"))

//檢查網頁是否存在

function checkurl(url)
{
  var xmlhttp = new activexobject("microsoft.xmlhttp");
  xmlhttp.open("get",url, false);
  try
  { 
    xmlhttp.send(); 
    var result = xmlhttp.status;
  }
  catch(e) {return(false); }
  if(result==200)
  { 
    return true;
  }
  xmlhttp = null;
  return false;
}

//連接數據庫

<script language="javascript">
  //用 javascript 寫服務器端連接數據庫的代碼示例
  var conn = new activexobject("adodb.connection");
  conn.open("provider=sqloledb.1; data source=localhost; user id=sa; "
    +"password=; initial catalog=pubs");
  var rs = new activexobject("adodb.recordset");
  var sql="select * from authors";
  rs.open(sql, conn);
 shtml = "<table width='100%' border=1>";
 shtml +="<tr bgcolor='#f4f4f4'><td>au_id</td><td>au_lname</td><td>au_fname</td><td>phone</td><td>address</td><td> city</td><td>state</td><td>zip</td></tr>";
  while(!rs.eof)
  {
 shtml += "<tr><td>" + rs("au_id") + "</td><td>" + rs("au_lname") + "</td><td>" + rs("au_fname") + "</td><td>" + rs("phone") + "</td><td>" + rs("address") + "</td><td>" + rs("city") + "</td><td>" + rs("state") + "</td><td>" + rs("zip") + "</td></tr>";
 rs.movenext;
  }
  shtml += "</table>";
  document.write(shtml);
  rs.close(); 
  rs = null; 
  conn.close(); 
  conn = null;
</script>

//使用數據島

<html>
<body>
srno:<input type=text datasrc=#xmldate datafld=srno size="76"><br>
times:<input type=text datasrc=#xmldate datafld=times size="76"><br>
<input id="first" type=button value="<< 第一條記錄" onclick="xmldate.recordset.movefirst()">
<input id="prev" type=button value="<上一條記錄" onclick="xmldate.recordset.moveprevious()">  
<input id="next" type=button value="下一條記錄>" onclick="xmldate.recordset.movenext()">  
<input id="last" type=button value="最后一條記錄>>" onclick="xmldate.recordset.movelast()">   
<input id="add" type=button value="添加新記錄" onclick="xmldate.recordset.addnew()">  
<xml id="xmldate">
<infolist>
<info ><srno>20041025-01</srno><times>null</times></info>
<info ><srno>20041101-09</srno><times>2004年10月1日2點22分0秒</times></info>
</infolist>
</xml>
</body>
</html>

//獲得參數

<body>
<a href="javascript:location.href=location.href + '?a=1&b=2'">search</a>
<script language="javascript">
<!--
var a = location.search.substr(1);
if(a.length>0)
{
 var re = /([^&]*?)/=([^&]*)/g
 var s = a.match(re);
 for(var i= 0;i<s.length;i++)
 {
  alert(s[i]);
  alert(s[i].split("=")[1]);
 }
}
//-->
</script>
</body>

//可編輯select

<input type=text name=re_name style="width:100px;height:21px;font-size:10pt;"><span style="width:18px;border:0px solid red;"><select name="r00" style="margin-left:-100px;width:118px; background-color:#ffeeee;" onchange="document.all.re_name.value=this.value;">
                <option value="1">11111111<option>
                <option value="2">222222</option>
                <option value="3">333333</option>
              </select>
              </span>


//設置光標位置

function getcaret(textbox)
{
var control = document.activeelement;
textbox.focus();
var rang = document.selection.createrange();
  rang.setendpoint("starttostart",textbox.createtextrange())
control.focus();
return rang.text.length;
}
function setcaret(textbox,pos)
{
try
{
  var r =textbox.createtextrange();
   r.movestart('character',pos);
   r.collapse(true);
   r.select();
}
catch(e)
{}
}
function selectlength(textbox,start,len)
{
try
{
  var r =textbox.createtextrange();
 
  r.moveend('character',len-(textbox.value.length-start));
  r.movestart('character',start);
  
  r.select();
}
catch(e)
{//alert(e.description)}
}
function insertatcaret(textbox,text)
{
textbox.focus();
document.selection.createrange().text = text;
}

//頁內查找

function findinpage(str)
{
var txt, i, found,n = 0;
if (str == "")
{
  return false;
}
txt = document.body.createtextrange();
for (i = 0; i <= n && (found = txt.findtext(str)) != false; i++)
{
  txt.movestart("character", 1);
  txt.moveend("textedit");
}
if (found)
{
  txt.movestart("character", -1);
  txt.findtext(str);
  txt.select();
  txt.scrollintoview();
  n++;  
}
else
{
  if (n > 0)
  {
   n = 0;
   findinpage(str);
  }
  else
  {
   alert(str + "...            您要找的文字不存在。/n /n請試著輸入頁面中的關鍵字再次查找!");
  }
}
return false;
}

//操作execl

<script language="javascript">
function jstartexcel() {
 var xls = new activexobject ( "excel.application" );
 xls.visible = true;
 var newbook = xls.workbooks.add;
 newbook.worksheets.add;
 newbook.worksheets(1).activate;
 xls.activeworkbook.activesheet.pagesetup.orientation = 2;
 xls.activeworkbook.activesheet.pagesetup.papersize = 5;
 newbook.worksheets(1).columns("a").columnwidth=50;
 newbook.worksheets(1).columns("a").wraptext = true;
 newbook.worksheets(1).columns("b").columnwidth=50;
 newbook.worksheets(1).columns("b").wraptext = true;
 newbook.worksheets(1).range("a1:b1000").numberformat = "0";
 newbook.worksheets(1).range("a1:b1000").horizontalalignment = -4131;
 newbook.worksheets(1).cells(1,1).interior.colorindex="15";
 newbook.worksheets(1).cells(1,1).value="first column, first cell";
 newbook.worksheets(1).cells(2,1).value="first column, second cell";
 newbook.worksheets(1).cells(1,2).value="second column, first cell";
 newbook.worksheets(1).cells(2,2).value="second column, second cell";
 newbook.worksheets(1).name="my first worksheet";
}
</script>

//自定義提示條

<a href="#" title="這是提示">tip</a>
<script language="javascript">
//***********默認設置定義.*********************
tpopwait=50;//停留twait豪秒后顯示提示。
tpopshow=5000;//顯示tshow豪秒后關閉提示
showpopstep=20;
popopacity=99;
//***************內部變量定義*****************
spop=null;
curshow=null;
tfadeout=null;
tfadein=null;
tfadewaiting=null;
document.write("<style type='text/css'id='defaultpopstyle'>");
document.write(".cpoptext {  background-color: #f8f8f5;color:#000000; border: 1px #000000 solid;font-color: font-size: 12px; padding-right: 4px; padding-left: 4px; height: 20px; padding-top: 2px; padding-bottom: 2px; filter: alpha(opacity=0)}");
document.write("</style>");
document.write("<div id='dypoplayer' style='position:absolute;z-index:1000;' class='cpoptext'></div>");
function showpopuptext(){
var o=event.srcelement;
mousex=event.x;
mousey=event.y;
if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};
        if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};
if(o.dypop!=spop) {
spop=o.dypop;
cleartimeout(curshow);
cleartimeout(tfadeout);
cleartimeout(tfadein);
cleartimeout(tfadewaiting);
if(spop==null || spop=="") {
dypoplayer.innerhtml="";
dypoplayer.style.filter="alpha()";
dypoplayer.filters.alpha.opacity=0;
}
else {
if(o.dyclass!=null) popstyle=o.dyclass 
else popstyle="cpoptext";
curshow=settimeout("showit()",tpopwait);
}
}
}
function showit(){
dypoplayer.classname=popstyle;
dypoplayer.innerhtml=spop;
popwidth=dypoplayer.clientwidth;
popheight=dypoplayer.clientheight;
if(mousex+12+popwidth>document.body.clientwidth) popleftadjust=-popwidth-24
else popleftadjust=0;
if(mousey+12+popheight>document.body.clientheight) poptopadjust=-popheight-24
else poptopadjust=0;
dypoplayer.style.left=mousex+12+document.body.scrollleft+popleftadjust;
dypoplayer.style.top=mousey+12+document.body.scrolltop+poptopadjust;
dypoplayer.style.filter="alpha(opacity=0)";
fadeout();
}
function fadeout(){
if(dypoplayer.filters.alpha.opacity<popopacity) {
dypoplayer.filters.alpha.opacity+=showpopstep;
tfadeout=settimeout("fadeout()",1);
}
else {
dypoplayer.filters.alpha.opacity=popopacity;
tfadewaiting=settimeout("fadein()",tpopshow);
}
}
function fadein(){
if(dypoplayer.filters.alpha.opacity>0) {
dypoplayer.filters.alpha.opacity-=1;
tfadein=settimeout("fadein()",1);
}
}
document.onmouseover=showpopuptext;
</script>


//插入文字

document.onclick =function(){ 
var osource = window.event.srcelement; 
if(osource.tagname!="div") 
return false; 
var sel = document.selection; 
if (sel!=null) { 
var rng = sel.createrange(); 
if (rng!=null) 
rng.pastehtml("<font color=red>插入文字</font>"); 


//netscapte下操作xml
doc = new activexobject("msxml2.domdocument");
doc = new activexobject("microsoft.xmldom")
->>
doc = (new domparser()).parsefromstring(sxml,'text/xml')

//判斷鍵值

<html>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<head>
<script language="javascript">
var ie  =navigator.appname=="microsoft internet explorer"?true:false;
  
function keydown(e)
{
 if(!ie)
 {
  var nkey=e.which;
  var iekey='現在是ns瀏覽器';
  var realkey=string.fromcharcode(e.which);
 }
 if(ie)
 {
  var iekey=event.keycode;
  var nkey='現在是ie瀏覽器';
  var realkey=string.fromcharcode(event.keycode);
  if(event.keycode==32){realkey='/' 空格/''}
  if(event.keycode==13){realkey='/' 回車/''}
  if(event.keycode==27){realkey='/' esc/''}
  if(event.keycode==16){realkey='/' shift/''}
  if(event.keycode==17){realkey='/' ctrl/''}
  if(event.keycode==18){realkey='/' alt/''}
 }
 alert('ns瀏覽器中鍵值:'+nkey+'/n'+'ie瀏覽器中鍵值:'+iekey+'/n'+'實際鍵為'+realkey);
}
document.onkeydown = keydown;
</script>
</head>
<body>
//javascript document.
<hr>
<center>
<h3>請按任意一個鍵。。。。</h3>
</center>
</body>
</html>

//禁止fso


1.注銷組件
regsvr32 /u scrrun.dll
2.修改progid 
hkey_classes_root/scripting.filesystemobject
scripting.filesystemobject
3.對于使用object的用戶,修改hkey_classes_root/scripting.

//省略號

<div style="width: 120px; height: 50px; border: 1px solid blue;
            overflow: hidden; text-overflow:ellipsis">
<nobr>就是比如有一行文字,很長,表格內一行顯示不下.</nobr>
</div>

//檢測media play版本

<ie:clientcaps id="oclientcaps" style="{behavior:url(#default#clientcaps)}" />
<script>
var flash="";
    wmpversion= oclientcaps.getcomponentversion("{22d6f312-b0f6-11d0-94ab-0080c74c7e95}","componentid"); 
    if (wmpversion != "") {
    flash = "";
    var version = wmpversion.split(",");
    var i;
    for (i = 0; i < version.length; i++) {
      if (i != 0)
    flash += ".";
      flash += version[i];
    }
     document.write("您的windows media player 版本是:"+flash+"<p>");
  }
</script>

//圖象按比例

<script language="javascript">
<!--
//圖片按比例縮放
var flag=false;
function drawimage(imgd){
 var image=new image();
 var iwidth = 80;  //定義允許圖片寬度
 var iheight = 80;  //定義允許圖片高度
 image.src=imgd.src;
 if(image.width>0 && image.height>0){
 flag=true;
 if(image.width/image.height>= iwidth/iheight){
  if(image.width>iwidth){  
  imgd.width=iwidth;
  imgd.height=(image.height*iwidth)/image.width;
  }else{
  imgd.width=image.width;  
  imgd.height=image.height;
  }
  imgd.alt=image.width+"&#215;"+image.height;
  }
 else{
  if(image.height>iheight){  
  imgd.height=iheight;
  imgd.width=(image.width*iheight)/image.height;  
  }else{
  imgd.width=image.width;  
  imgd.height=image.height;
  }
  imgd.alt=image.width+"&#215;"+image.height;
  }
 }

//-->
</script>
<img src=".." onload = "drawimage(this)">

//細線select

<span style="border:1px solid #000000; position:absolute; overflow:hidden;" >
<select style="margin:-2px;">
<option>1111</option>
<option>11111111111111</option>
<option>111111111</option>
</select></span>

//import

function import() {
for( var i=0; i<arguments.length; i++ ) {
  var file = arguments[i];
  if ( file.match(//.js$/i)) 
   document.write('<script type=/"text/javascript/" src=/"' + file + '/"></sc' + 'ript>');
  else
   document.write('<style type=/"text/css/">@import /"' + file + '/" ;</style>');
}
};


//js枚舉

function getcomputername()
{
var objwmiservice = getobject("winmgmts:root/cimv2");
for(e = new enumerator(objwmiservice) ; !e.atend() ; e.movenext())
{
    var getcomputer = e.item();
    return getcomputer.name;
}
}

//條件編譯

<script language=javascript>
/*@cc_on @*/
/*@if (@_win32 && @_jscript_version>5)
function window.confirm(str)
{
    execscript("n = msgbox('"+ str +"', 257)", "vbscript");
    return(n == 1);
}
@end @*/
</script>

//取得innertext

<script language="javascript">
<!--
 var xmldoc = new activexobject("msxml2.domdocument.4.0");
 var currnode;
 xmldoc.async = false;
 xmldoc.async = false;
 xmldoc.loadxml("<tablename>      你好你阿三    大法     司法等四              </tablename>");
 currnode = xmldoc.documentelement;
   
  var s = currnode.xml;
  var r = //<([^/>/s]*?)[^/>]*?/>([^/<]*?)/<///1/>/
  var b = s.replace(r,"$2");
  alert(b);
//-->
</script>
//mergeattributes 復制所有讀/寫標簽屬性到指定元素。
<script>
function fnmerge(){
osource.children[1].mergeattributes(osource.children[0]);
}
</script>
<span id=osource>
<div
id="odiv"
attribute1="true"
attribute2="true"
onclick="alert('click');"
onmouseover="this.style.color='#0000ff';"
onmouseout="this.style.color='#000000';"
>
this is a sample <b>div</b> element.
</div>
<div id="odiv2">
this is another sample <b>div</b> element.
</div>
</span>
<input
type="button"
value="merge attributes"
onclick="fnmerge()"
>

檢查鏈接是否有效

<a href=http://www.49028c.com onclick="mm(this, 'http://www.49028c.com/')">test</a>
<script language="javascript">
function geturl(url)
{
var xmlhttp = new activexobject("microsoft.xmlhttp");
xmlhttp.open("get",url,false);
xmlhttp.send();
if (xmlhttp.readystate==4) return xmlhttp.status==200;
return false;
}
function mm(e, url)
{
if(!geturl(e.href)) e.href = url;
}
</script>

判斷是否輸入值再激活按鈕

<script>
function check(){
s.disabled = (t1.value == '' || t2.value == '' || t3.value == '')
}
</script>
<input name="t1" onpropertychange="check();">
<input name="t2" onpropertychange="check();">
<input name="t3" onpropertychange="check();">
<input type="submit" name="s" disabled>

屏蔽鼠標右鍵、ctrl+n、shift+f10、alt+f4、f11、f5刷新、退格鍵

<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=gb2312">
  <noscript><meta http-equiv="refresh" content="0;url=about:noscript"></noscript>
  <title>屏蔽鼠標右鍵、ctrl+n、shift+f10、alt+f4、f11、f5刷新、退格鍵</title>
</head>
<body>
<script language="javascript"><!--
  //屏蔽鼠標右鍵、ctrl+n、shift+f10、f11、f5刷新、退格鍵
  //author: meizz(梅花雨) 2002-6-18
function document.oncontextmenu(){event.returnvalue=false;}//屏蔽鼠標右鍵
function window.onhelp(){return false} //屏蔽f1幫助
function document.onkeydown()
{
  if ((window.event.altkey)&&
      ((window.event.keycode==37)||   //屏蔽 alt+ 方向鍵 ←
       (window.event.keycode==39)))   //屏蔽 alt+ 方向鍵 →
  {
     alert("不準你使用alt+方向鍵前進或后退網頁!");
     event.returnvalue=false;
  }
     /* 注:這還不是真正地屏蔽 alt+ 方向鍵,
     因為 alt+ 方向鍵彈出警告框時,按住 alt 鍵不放,
     用鼠標點掉警告框,這種屏蔽方法就失效了。以后若
     有哪位高手有真正屏蔽 alt 鍵的方法,請告知。*/
  if ((event.keycode==8)  ||                 //屏蔽退格刪除鍵
      (event.keycode==116)||                 //屏蔽 f5 刷新鍵
      (event.ctrlkey && event.keycode==82)){ //ctrl + r
     event.keycode=0;
     event.returnvalue=false;
     }
  if (event.keycode==122){event.keycode=0;event.returnvalue=false;}  //屏蔽f11
  if (event.ctrlkey && event.keycode==78) event.returnvalue=false;   //屏蔽 ctrl+n
  if (event.shiftkey && event.keycode==121)event.returnvalue=false;  //屏蔽 shift+f10
  if (window.event.srcelement.tagname == "a" && window.event.shiftkey) 
      window.event.returnvalue = false;             //屏蔽 shift 加鼠標左鍵新開一網頁
  if ((window.event.altkey)&&(window.event.keycode==115))             //屏蔽alt+f4
  {
      window.showmodelessdialog("about:blank","","dialogwidth:1px;dialogheight:1px");
      return false;
  }
}
</script>
屏蔽鼠標右鍵、ctrl+n、shift+f10、alt+f4、f11、f5刷新、退格鍵
</body>
</html>

自定義熱鍵(請按a)

自定義熱鍵(請按a)
<script language="javascript">
<!--
var hotkey=97
var destination="http://www.49028c.com"
if (document.layers)
document.captureevents(event.keypress)
function backhome(e){
if (document.layers){
if (e.which==hotkey)
window.location=destination
}
else if (document.all){
if (event.keycode==hotkey)
window.location=destination
}
}
document.onkeypress=backhome
//-->
</script>

下面的是用javascript傳遞參數。如果本文件為test.htm,如果訪問 test.htm?12 則javascript會得到?后的值并用document.all替換iframe的src值。

<iframe height="750" width="760" scrolling="no" src="view.jsp" id="u" frameborder="0"></iframe>
<script language="javascript">
var url=window.location.href;
var s=url.indexof("?");
if(s!=-1)
{
    var src=url.substring(s+1);
    document.all.u.src="view.jsp?id="+src;
   
}
</script>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
粉嫩老牛aⅴ一区二区三区| 国产精品色视频| 国产欧美日韩精品丝袜高跟鞋| 中日韩美女免费视频网址在线观看| 91麻豆国产语对白在线观看| www.久久久久久.com| 日韩成人中文字幕在线观看| 色婷婷av一区二区三区在线观看| 日韩h在线观看| 91久久精品久久国产性色也91| 性欧美暴力猛交69hd| 欧美小视频在线观看| 国产精品扒开腿做爽爽爽的视频| 久久天天躁日日躁| www国产亚洲精品久久网站| 日韩在线免费高清视频| 日本在线观看天堂男亚洲| 久久全国免费视频| 精品国产鲁一鲁一区二区张丽| 欧美极品在线视频| 亚洲一区二区日本| 久久久久久亚洲精品中文字幕| 欧美成年人网站| 久久久久久亚洲精品中文字幕| 在线视频日本亚洲性| 欧美精品成人在线| 国产精品日韩一区| 国产欧美亚洲精品| 日韩美女免费视频| 美女久久久久久久久久久| 欧美在线视频a| 日韩精品中文字幕在线播放| 国产在线精品自拍| 国产精品国产三级国产专播精品人| 国产一区二区三区丝袜| 亚洲成人av片| 国产成人综合久久| 久久久亚洲精选| 欧美日韩在线视频一区| 成人免费在线网址| 亚洲欧美制服中文字幕| 欧美激情精品久久久| 97色在线观看免费视频| 国产精品久久久久久中文字| 成人妇女淫片aaaa视频| 成人免费看黄网站| 2019av中文字幕| 国产成人精品久久二区二区91| 欧美老少做受xxxx高潮| 久久激情视频久久| 日韩在线视频线视频免费网站| 性视频1819p久久| 国产欧美在线观看| 日韩精品中文字幕在线观看| 亚洲欧美另类中文字幕| 久久精品99久久久香蕉| 亚洲欧美国内爽妇网| 久久国产精品首页| 色中色综合影院手机版在线观看| 日韩av网站大全| 欧洲成人午夜免费大片| 欧美激情精品久久久久久久变态| 亚洲天堂av在线免费| 国精产品一区一区三区有限在线| 久久亚洲精品毛片| 欧美大成色www永久网站婷| 国语自产精品视频在线看| 亚洲精品美女免费| 欧洲亚洲妇女av| 亚洲91av视频| 午夜精品久久久久久久久久久久久| 亚洲经典中文字幕| 午夜精品久久久久久久男人的天堂| 亚洲精品自拍第一页| 国产日韩精品在线| 亚洲美女在线看| 曰本色欧美视频在线| 91精品视频免费观看| 久久精品国产精品| 在线播放精品一区二区三区| 久久久久久久97| 中文字幕欧美日韩精品| 亚洲电影免费观看高清完整版在线| 国产精品黄色影片导航在线观看| 黄色精品在线看| 国产精品扒开腿做爽爽爽的视频| 午夜免费久久久久| 性欧美激情精品| 国产成人精品一区二区三区| 国产精品福利无圣光在线一区| 欧美日韩国产中文精品字幕自在自线| 欧美亚洲视频在线观看| 精品视频久久久久久久| 国产精品国产自产拍高清av水多| 色哟哟亚洲精品一区二区| 欧美国产日产韩国视频| 尤物99国产成人精品视频| 国产欧美一区二区三区视频| 国产精品69av| 日韩经典中文字幕| 精品av在线播放| 日韩国产在线播放| 亚洲自拍小视频免费观看| 久久人人爽亚洲精品天堂| 欧美黑人又粗大| 国产免费一区二区三区在线能观看| 国产精品午夜一区二区欲梦| 在线播放亚洲激情| 一区二区中文字幕| 久久精品视频免费播放| 欧美裸体xxxx极品少妇软件| 亚洲色图五月天| 亚洲sss综合天堂久久| 欧美精品电影在线| 日韩国产精品视频| 国语自产精品视频在线看抢先版图片| 亚洲自拍高清视频网站| 日韩欧美大尺度| 亚洲视频在线视频| 国产精品久久久久久久久久久久| 日韩av在线免费观看一区| 狠狠躁天天躁日日躁欧美| 国产va免费精品高清在线| 狠狠色香婷婷久久亚洲精品| 68精品久久久久久欧美| 青青a在线精品免费观看| 中文字幕一区二区精品| 北条麻妃一区二区在线观看| 91青草视频久久| 在线成人中文字幕| 国产成人在线视频| 国产精品高清在线观看| 一区二区欧美激情| 九九久久国产精品| 欧美巨乳在线观看| 亚洲xxxxx| 97精品视频在线观看| 久久久噜久噜久久综合| 欧美国产日韩免费| 亚洲成人黄色在线观看| 欧美日韩久久久久| 久久亚洲精品视频| 亚洲精品福利免费在线观看| 久久精品国产69国产精品亚洲| 欧美日韩在线免费| 日韩亚洲精品视频| 97av视频在线| 97视频在线观看免费高清完整版在线观看| 欧美日韩国产中字| yellow中文字幕久久| 日韩美女免费观看| 性欧美xxxx视频在线观看| 亚洲国产婷婷香蕉久久久久久| 亚洲欧美中文在线视频| 精品视频偷偷看在线观看| www.久久久久| 亚洲 日韩 国产第一| 亚洲欧美色图片| 1769国内精品视频在线播放| 夜夜狂射影院欧美极品| 中文字幕久久久av一区| 亚洲福利视频专区| 国产精品亚洲一区二区三区| 日本人成精品视频在线|