欧美高清成人,一区二区久久久久久,9999久久久久http://www.aygfsteel.com/dreamstone/category/24604.html開發出高質量的系統zh-cnFri, 14 Sep 2007 04:48:07 GMTFri, 14 Sep 2007 04:48:07 GMT60javascript 動態添加刪除控件http://www.aygfsteel.com/dreamstone/archive/2007/09/14/144111.htmldreamstonedreamstoneFri, 14 Sep 2007 01:39:00 GMThttp://www.aygfsteel.com/dreamstone/archive/2007/09/14/144111.htmlhttp://www.aygfsteel.com/dreamstone/comments/144111.htmlhttp://www.aygfsteel.com/dreamstone/archive/2007/09/14/144111.html#Feedback0http://www.aygfsteel.com/dreamstone/comments/commentRss/144111.htmlhttp://www.aygfsteel.com/dreamstone/services/trackbacks/144111.html<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>

<BODY>
<script language="javascript">
var i = 0,j = 0;     //行號與列號
var oNewRow  ;    //定義插入行對象
var oNewCell1,oNewCell2;     //定義插入列對象

//添加條件行
function AddRow()
{
= document.all.MyTable.rows.length;
oNewRow 
= document.all.MyTable.insertRow(i);
oNewRow.id 
= j;

//添加第一列
oNewCell1 = document.all.MyTable.rows[i].insertCell(0)
oNewCell1.innerHTML 
= "<input type='text' id='Value" + j + "'"+" size='14' value=\"\">";

//添加第二列
oNewCell2 = document.all.MyTable.rows[i].insertCell(1)
oNewCell2.innerHTML 
="<input type=button name=Del" + j + " value='刪除當前行'"+"onClick='DelCurrentRow(" + j + ");'>";
j
++;
}


//刪除行
function DelCurrentRow(j)
{
with(document.all.MyTable)
{
for (var i=0;i<rows.length;i++)
{
if (rows[i].id == j)
{
deleteRow(i);
}

}

}

}

</script>

<form method="post" action="">
<div style="margin-left:80px;color:red;font-weight:bold;"></div>
<div align="center" class="title-font">
動態添加HTML元素
</div>
<br>
<table style="border:0px;" cellpadding=0 cellspacing=0
     align
="center">
<tr>
<td style="border:0px;" width="340"><hr></td>
<td style="border:0px;"><input type=button value="添加" name"addFieldBT" onclick="AddRow();"/></td>
</tr>
</table>
<br><br>
<table style="border:0px;" cellpadding=0 cellspacing=0
   align
="center" class="TableBody" id="MyTable" border="0">
</table>
<br><br>
<table style="border:0px;" cellpadding=0 cellspacing=0
   align
="center">
  
<tr>
   
<td align="center" style="border:0px;">
   
<input type=button value="提交" name="searchBT" onclick=""/>
   
</td>
  
</tr>
</table>
<script language="javascript">AddRow()</script>
</form>
</BODY>
</HTML>


dreamstone 2007-09-14 09:39 發表評論
]]>
javascript 關聯列表的實現(簡單的和復雜的)http://www.aygfsteel.com/dreamstone/archive/2007/09/14/144114.htmldreamstonedreamstoneFri, 14 Sep 2007 01:39:00 GMThttp://www.aygfsteel.com/dreamstone/archive/2007/09/14/144114.htmlhttp://www.aygfsteel.com/dreamstone/comments/144114.htmlhttp://www.aygfsteel.com/dreamstone/archive/2007/09/14/144114.html#Feedback0http://www.aygfsteel.com/dreamstone/comments/commentRss/144114.htmlhttp://www.aygfsteel.com/dreamstone/services/trackbacks/144114.html閱讀全文

dreamstone 2007-09-14 09:39 發表評論
]]>
最簡單的ajax實現http://www.aygfsteel.com/dreamstone/archive/2007/09/10/144107.htmldreamstonedreamstoneMon, 10 Sep 2007 15:00:00 GMThttp://www.aygfsteel.com/dreamstone/archive/2007/09/10/144107.htmlhttp://www.aygfsteel.com/dreamstone/comments/144107.htmlhttp://www.aygfsteel.com/dreamstone/archive/2007/09/10/144107.html#Feedback0http://www.aygfsteel.com/dreamstone/comments/commentRss/144107.htmlhttp://www.aygfsteel.com/dreamstone/services/trackbacks/144107.html<script type="text/javascript" language="javascript">

    
var http_request = false;

    
function makeRequest(url) {

        http_request 
= false;

        
if (window.XMLHttpRequest) // Mozilla, Safari,
            http_request = new XMLHttpRequest();
            
if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text
/xml');
            }

        }
 else if (window.ActiveXObject) // IE
            try {
                http_request 
= new ActiveXObject("Msxml2.XMLHTTP");
            }
 catch (e) {
                
try {
                    http_request 
= new ActiveXObject("Microsoft.XMLHTTP");
                }
 catch (e) {}
            }

        }


        
if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            
return false;
        }

        http_request.onreadystatechange 
= alertContents;
        http_request.open('GET', url, 
true);
        http_request.send(
null);

    }


    
function alertContents() {

        
if (http_request.readyState == 4{
            
if (http_request.status == 200{
                alert(http_request.responseText);
            }
 else {
                alert('There was a problem 
with the request.');
            }

        }


    }

</script>
<span
    style
="cursor: pointer; text-decoration: underline"
    onclick
="makeRequest('test.html')">
        Make a request
</span>


dreamstone 2007-09-10 23:00 發表評論
]]>
javascript兩種漸變效果進度條的實現http://www.aygfsteel.com/dreamstone/archive/2007/09/10/144105.htmldreamstonedreamstoneMon, 10 Sep 2007 14:58:00 GMThttp://www.aygfsteel.com/dreamstone/archive/2007/09/10/144105.htmlhttp://www.aygfsteel.com/dreamstone/comments/144105.htmlhttp://www.aygfsteel.com/dreamstone/archive/2007/09/10/144105.html#Feedback1http://www.aygfsteel.com/dreamstone/comments/commentRss/144105.htmlhttp://www.aygfsteel.com/dreamstone/services/trackbacks/144105.html閱讀全文

dreamstone 2007-09-10 22:58 發表評論
]]>
vb script實現殺掉進程http://www.aygfsteel.com/dreamstone/archive/2007/09/10/144104.htmldreamstonedreamstoneMon, 10 Sep 2007 14:54:00 GMThttp://www.aygfsteel.com/dreamstone/archive/2007/09/10/144104.htmlhttp://www.aygfsteel.com/dreamstone/comments/144104.htmlhttp://www.aygfsteel.com/dreamstone/archive/2007/09/10/144104.html#Feedback0http://www.aygfsteel.com/dreamstone/comments/commentRss/144104.htmlhttp://www.aygfsteel.com/dreamstone/services/trackbacks/144104.html' ProcessKillLocal.vbs
'
 Sample VBScript to kill a program
'
 Author Guy Thomas http://computerperformance.co.uk/
'
 Version 2.7 - December 2005
'
 ------------------------ -------------------------------' 
Option Explicit
Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill 
strComputer 
= "."
strProcessKill 
= "'otrun.exe'" 

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _ 
& strComputer & "\root\cimv2"

Set colProcess = objWMIService.ExecQuery _
(
"Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
Next 
WSCript.Echo 
"Just killed process " & strProcessKill _
& " on " & strComputer
WScript.Quit 
' End of WMI Example of a Kill Process 


dreamstone 2007-09-10 22:54 發表評論
]]>
javascript 禁止輸入、禁止粘帖、禁止拖放、禁止輸入法http://www.aygfsteel.com/dreamstone/archive/2007/09/10/144103.htmldreamstonedreamstoneMon, 10 Sep 2007 14:50:00 GMThttp://www.aygfsteel.com/dreamstone/archive/2007/09/10/144103.htmlhttp://www.aygfsteel.com/dreamstone/comments/144103.htmlhttp://www.aygfsteel.com/dreamstone/archive/2007/09/10/144103.html#Feedback0http://www.aygfsteel.com/dreamstone/comments/commentRss/144103.htmlhttp://www.aygfsteel.com/dreamstone/services/trackbacks/144103.html function regInput(str){  
 reg=/^[a-z]*$/;
 return reg.test(str)
}
</script>
<input type="text"
 onkeypress = "return regInput(String.fromCharCode(event.keyCode))"
 onpaste = "return regInput(window.clipboardData.getData('Text'))"
 ondrop = "return regInput(event.dataTransfer.getData('Text'))"
 style="ime-mode:Disabled"><br>
<input type="text"><br><br>

另外如果要兼容ie ,firefox netscapt三個瀏覽器,就不能用onkeypress事件。
而應該把onkeypress事件變成 onkeydown事件+onkeyup事件。
再keydown事件中檢查,并設置標志位,在onkeyup事件中返回,類似這樣
script language="javascript">
 var tag;
    function kd(evt) {
  alert(evt.keyCode);
  if (evt.keyCode >= 48 && evt.keyCode <= 57) {
   tag=true; 
   return;
  }else{
   if (evt.keyCode==8){
    tag=true;
    return;
   }
  }
  tag=false;
 }
 function kp(){
  return tag;
 }
</script>
至于為什么這樣,自己測試一下不這樣的結果吧

dreamstone 2007-09-10 22:50 發表評論
]]>
javascript 格式化數字http://www.aygfsteel.com/dreamstone/archive/2007/09/10/144096.htmldreamstonedreamstoneMon, 10 Sep 2007 14:02:00 GMThttp://www.aygfsteel.com/dreamstone/archive/2007/09/10/144096.htmlhttp://www.aygfsteel.com/dreamstone/comments/144096.htmlhttp://www.aygfsteel.com/dreamstone/archive/2007/09/10/144096.html#Feedback0http://www.aygfsteel.com/dreamstone/comments/commentRss/144096.htmlhttp://www.aygfsteel.com/dreamstone/services/trackbacks/144096.html<script>

function formatNumber(number,pattern){
    
var str            = number.toString();
    
var strInt;
    
var strFloat;
    
var formatInt;
    
var formatFloat;
    
if(/\./g.test(pattern)){
        formatInt        
= pattern.split('.')[0];
        formatFloat        
= pattern.split('.')[1];
    }
else{
        formatInt        
= pattern;
        formatFloat        
= null;
    }


    
if(/\./g.test(str)){
        
if(formatFloat!=null){
            
var tempFloat    = Math.round(parseFloat('0.'+str.split('.')[1])*Math.pow(10,formatFloat.length))/Math.pow(10,formatFloat.length);
            strInt        
= (Math.floor(number)+Math.floor(tempFloat)).toString();                
            strFloat    
= /\./g.test(tempFloat.toString())?tempFloat.toString().split('.')[1]:'0';            
        }
else{
            strInt        
= Math.round(number).toString();
            strFloat    
= '0';
        }

    }
else{
        strInt        
= str;
        strFloat    
= '0';
    }

    
if(formatInt!=null){
        
var outputInt    = '';
        
var zero        = formatInt.match(/0*$/)[0].length;
        
var comma        = null;
        
if(/,/g.test(formatInt)){
            comma        
= formatInt.match(/,[^,]*/)[0].length-1;
        }

        
var newReg        = new RegExp('(\\d{'+comma+'})','g');

        
if(strInt.length<zero){
            outputInt        
= new Array(zero+1).join('0')+strInt;
            outputInt        
= outputInt.substr(outputInt.length-zero,zero)
        }
else{
            outputInt        
= strInt;
        }


        
var 
        outputInt            
= outputInt.substr(0,outputInt.length%comma)+outputInt.substring(outputInt.length%comma).replace(newReg,(comma!=null?',':'')+'$1')
        outputInt            
= outputInt.replace(/^,/,'');

        strInt    
= outputInt;
    }


    
if(formatFloat!=null){
        
var outputFloat    = '';
        
var zero        = formatFloat.match(/^0*/)[0].length;

        
if(strFloat.length<zero){
            outputFloat        
= strFloat+new Array(zero+1).join('0');
            
//outputFloat        = outputFloat.substring(0,formatFloat.length);
            var outputFloat1    = outputFloat.substring(0,zero);
            
var outputFloat2    = outputFloat.substring(zero,formatFloat.length);
            outputFloat        
= outputFloat1+outputFloat2.replace(/0*$/,'');
        }
else{
            outputFloat        
= strFloat.substring(0,formatFloat.length);
        }


        strFloat    
= outputFloat;
    }
else{
        
if(pattern!='' || (pattern=='' && strFloat=='0')){
            strFloat    
= '';
        }

    }


    
return strInt+(strFloat==''?'':'.'+strFloat);
}


alert(formatNumber(
0,''));
alert(formatNumber(
12432.21,'#,###'));
alert(formatNumber(
12432.21,'#,###.000#'));
alert(formatNumber(
12432,'#,###.00'));
alert(formatNumber('
12432.415','#,###.0#'));


</script>


dreamstone 2007-09-10 22:02 發表評論
]]>
用vbscript來重寫javascripthttp://www.aygfsteel.com/dreamstone/archive/2007/09/10/144018.htmldreamstonedreamstoneMon, 10 Sep 2007 07:45:00 GMThttp://www.aygfsteel.com/dreamstone/archive/2007/09/10/144018.htmlhttp://www.aygfsteel.com/dreamstone/comments/144018.htmlhttp://www.aygfsteel.com/dreamstone/archive/2007/09/10/144018.html#Feedback0http://www.aygfsteel.com/dreamstone/comments/commentRss/144018.htmlhttp://www.aygfsteel.com/dreamstone/services/trackbacks/144018.html 可以嘗試用vbscript來重寫javascript,雖然這種方法也有很多弊端。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<script  language=javascript>
    
function msg(){            
          execScript(
"n=msgbox('是否保存',4,'自定的的confirm')","vbscript");   
          alert(n);
          
return(n == 1);      
  }
   
</script>
<BODY>
    
<input type="button" onclick="msg()" value="click" />
</BODY>
</HTML>


dreamstone 2007-09-10 15:45 發表評論
]]>
js轉換中把10進制數字轉換成16進制http://www.aygfsteel.com/dreamstone/archive/2007/09/10/144014.htmldreamstonedreamstoneMon, 10 Sep 2007 07:40:00 GMThttp://www.aygfsteel.com/dreamstone/archive/2007/09/10/144014.htmlhttp://www.aygfsteel.com/dreamstone/comments/144014.htmlhttp://www.aygfsteel.com/dreamstone/archive/2007/09/10/144014.html#Feedback0http://www.aygfsteel.com/dreamstone/comments/commentRss/144014.htmlhttp://www.aygfsteel.com/dreamstone/services/trackbacks/144014.html  
var x = 33;
 
alert(x.toString(16));
 
</script>

dreamstone 2007-09-10 15:40 發表評論
]]>
javascript中的各種輸入限制http://www.aygfsteel.com/dreamstone/archive/2007/09/10/144013.htmldreamstonedreamstoneMon, 10 Sep 2007 07:37:00 GMThttp://www.aygfsteel.com/dreamstone/archive/2007/09/10/144013.htmlhttp://www.aygfsteel.com/dreamstone/comments/144013.htmlhttp://www.aygfsteel.com/dreamstone/archive/2007/09/10/144013.html#Feedback1http://www.aygfsteel.com/dreamstone/comments/commentRss/144013.htmlhttp://www.aygfsteel.com/dreamstone/services/trackbacks/144013.html1.文本框輸入限制

實現限制輸入大、小寫英文,數字,浮點小數,日期,中文,部分英文,部分中文等眾多功能。直接加入到html代碼中即可使用。

<script>
function regInput(obj, reg, inputStr)
{
var docSel = document.selection.createRange()
if (docSel.parentElement().tagName != "INPUT") return false
oSel = docSel.duplicate()
oSel.text = ""
var srcRange = obj.createTextRange()
oSel.setEndPoint("StartToStart", srcRange)
var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
return reg.test(str)
}
</script>

小寫英文:<xmp style= "display:inline"> </xmp>
<input onkeypress = "return regInput(this, /^[a-z]*$/, String.fromCharCode(event.keyCode))"
onpaste = "return regInput(this, /^[a-z]*$/, window.clipboardData.getData('Text'))"
ondrop = "return regInput(this, /^[a-z]*$/, event.dataTransfer.getData('Text'))"
style="ime-mode:Disabled"><br>

大寫英文:<xmp style= "display:inline"> </xmp>
<input onkeypress = "return regInput(this, /^[A-Z]*$/, String.fromCharCode(event.keyCode))"
onpaste = "return regInput(this, /^[A-Z]*$/, window.clipboardData.getData('Text'))"
ondrop = "return regInput(this, /^[A-Z]*$/, event.dataTransfer.getData('Text'))"
style="ime-mode:Disabled">
<br>

任意數字:<xmp style="display:inline"> </xmp>
<input onkeypress = "return regInput(this, /^[0-9]*$/, String.fromCharCode(event.keyCode))"
onpaste = "return regInput(this, /^[0-9]*$/, window.clipboardData.getData('Text'))"
ondrop = "return regInput(this, /^[0-9]*$/, event.dataTransfer.getData('Text'))"
style="ime-mode:Disabled"><br>

限2位小數:<xmp style="display:inline"> </xmp>
<input onkeypress = "return regInput(this, /^\d*\.?\d{0,2}$/,
String.fromCharCode(event.keyCode))"
onpaste = "return regInput(this, /^\d*\.?\d{0,2}$/,
window.clipboardData.getData('Text'))"
ondrop = "return regInput(this, /^\d*\.?\d{0,2}$/,
event.dataTransfer.getData('Text'))"
style="ime-mode:Disabled">

如: 123.12<br>

日  期:<xmp style="display:inline"> </xmp>

<input onkeypress = "return regInput(this, /^\d{1,4}
([-\/](\d{1,2}([-\/](\d{1,2})?)?)?)?$/,
String.fromCharCode(event.keyCode))"

onpaste = "return regInput(this, /^\d{1,4}([-\/](\d{1,2}
([-\/](\d{1,2})?)?)?)?$/,
window.clipboardData.getData('Text'))"

ondrop = "return regInput(this, /^\d{1,4}([-\/](\d{1,2}
([-\/](\d{1,2})?)?)?)?$/,
event.dataTransfer.getData('Text'))"

style="ime-mode:Disabled">

如: 2002-9-29<br>

任意中文:<xmp style="display:inline"> </xmp>

<input onkeypress = "return regInput(this, /^$/,
String.fromCharCode(event.keyCode))"

onpaste = "return regInput(this, /^[\u4E00-\u9FA5]*$/,
window.clipboardData.getData('Text'))"

ondrop = "return regInput(this, /^[\u4E00-\u9FA5]*$/,
event.dataTransfer.getData('Text'))"><br>

部分英文:<xmp style="display:inline"> </xmp>
<input onkeypress = "return regInput(this, /^[a-e]*$/,
String.fromCharCode(event.keyCode))"

onpaste = "return regInput(this, /^[a-e]*$/,
window.clipboardData.getData('Text'))"

ondrop = "return regInput(this, /^[a-e]*$/,
event.dataTransfer.getData('Text'))"

style="ime-mode:Disabled">

范圍: a,b,c,d,e<br>

部分中文:<xmp style="display:inline"> </xmp>
<script language=javascript>

function checkChinese(oldLength, obj)
{
var oTR = window.document.selection.createRange()
var reg = /[^一二三四五六七八九十]/g
oTR.moveStart("character", -1*(obj.value.length-oldLength))
oTR.text = oTR.text.replace(reg, "")
}
</script>

<input onkeypress="return false" onkeydown=
"setTimeout('checkChinese('+this.value.length+','+this.uniqueID+')',
1)"

onpaste = "return regInput(this, /^[一二三四五六七八九十]*$/,
window.clipboardData.getData('Text'))"

ondrop = "return regInput(this, /^[一二三四五六七八九十]*$/,
event.dataTransfer.getData('Text'))">

范圍: 一二三四五六七八九十<br>

2.不能展開右鍵,不能全選,不能復制的實現

<body oncontextmenu="window.event.returnvalue=false"
onkeypress="window.event.returnvalue=false"
onkeydown="window.event.returnvalue=false"
onkeyup="window.event.returnvalue=false"
ondragstart="window.event.returnvalue=false"
onselectstart="event.returnvalue=false">
...
</body>

3.禁止頁面正文內容被選取

<body oncontextmenu="return false" ondragstart="return false"
onselectstart ="return false" onselect="document.selection.empty()"
oncopy="document.selection.empty()" onbeforecopy="return false"onmouseup="document.selection.empty()">

4.避免別人把網頁放在框架中

<script language=“javascript”><!--if (self!=top){top.location=self.location;}-->< /script>

5.禁示查看源代碼

<frameset>
<frame src="你要保密的文件的URL">
</frameset>

6.關閉輸入法

<input style="ime-mode:disabled">

7.禁止圖片下載

在這里的最后加入:

oncontextmenu="return false" ondragstart="return false" onselectstart="return
false" scroll="auto"

8.禁止緩存

在HEAD里加入:

<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">



dreamstone 2007-09-10 15:37 發表評論
]]>
javascript中實現動態廣告的方法http://www.aygfsteel.com/dreamstone/archive/2007/09/10/144012.htmldreamstonedreamstoneMon, 10 Sep 2007 07:31:00 GMThttp://www.aygfsteel.com/dreamstone/archive/2007/09/10/144012.htmlhttp://www.aygfsteel.com/dreamstone/comments/144012.htmlhttp://www.aygfsteel.com/dreamstone/archive/2007/09/10/144012.html#Feedback0http://www.aygfsteel.com/dreamstone/comments/commentRss/144012.htmlhttp://www.aygfsteel.com/dreamstone/services/trackbacks/144012.html閱讀全文

dreamstone 2007-09-10 15:31 發表評論
]]>
js中實現table的插入、修改、刪除http://www.aygfsteel.com/dreamstone/archive/2007/09/10/144008.htmldreamstonedreamstoneMon, 10 Sep 2007 07:24:00 GMThttp://www.aygfsteel.com/dreamstone/archive/2007/09/10/144008.htmlhttp://www.aygfsteel.com/dreamstone/comments/144008.htmlhttp://www.aygfsteel.com/dreamstone/archive/2007/09/10/144008.html#Feedback0http://www.aygfsteel.com/dreamstone/comments/commentRss/144008.htmlhttp://www.aygfsteel.com/dreamstone/services/trackbacks/144008.html閱讀全文

dreamstone 2007-09-10 15:24 發表評論
]]>
面向對象(OOP)方法使用 JavaScripthttp://www.aygfsteel.com/dreamstone/archive/2007/05/22/119200.htmldreamstonedreamstoneTue, 22 May 2007 10:07:00 GMThttp://www.aygfsteel.com/dreamstone/archive/2007/05/22/119200.htmlhttp://www.aygfsteel.com/dreamstone/comments/119200.htmlhttp://www.aygfsteel.com/dreamstone/archive/2007/05/22/119200.html#Feedback3http://www.aygfsteel.com/dreamstone/comments/commentRss/119200.htmlhttp://www.aygfsteel.com/dreamstone/services/trackbacks/119200.htmlprivate variables:原始的定義變量的方法 var
private functions:通過 var functionName=function(){}聲明

privileged methods: 通過this.methodName=function(){}聲明
privileged properties:通過 this.variableName來聲明
(有些地方把privileged properties叫做public properties,但我感覺無論是按照
定義寫法,還是為了便于理解都叫privileged properties更好些。更便于對比對稱記憶)

prototype methods :通過Classname.prototype.methodname=function(){}來聲明
(有些地方叫public method,同樣和上邊一樣的理由,這里改叫prototype method)
prototype properties:通過 classname.prototype.propertyName=somevalue來聲明

static properties: 通過classname.propertyName=somevalue定義
static method :通過classnamne.methodName來聲明

說明:有些地方(例如我看的文檔中)把privileged properties和prototype method叫成
public properties 和public method,不知道為什么這樣叫。這樣命名后造成的問題是
1,privileged method沒有對應的privileged properties
2,prototype properties沒有對應的prototype method
3,public method和public properties的定義方式又不對稱

下邊解釋一下幾種情況:
1,private:定義在類內部,只能被類內部的方法調用,例如privileged(見實例一中的(1)(2))
2,priviledged :定義在類內部,能被任何調用,在調用上有點類似Java中
的非靜態public方法(見實例一中的(3))
3,prototype:這個概念不太好理解,在執行上有點像java的clone,只在類初始化的時候
執行一次。每次建立實例的時候不執行。能被繼承。
4,static: 有點類似java中的靜態。各實例共享,不能被繼承
實例一如下:

<script>
        function Pet(name,color)
{
            
//priviledged properties
            this.name=name;
            
this.color=color;
            
//private properties
            var type="animal";
            
//private method
            var run2 = function(){
                run(type);
            }

            var run 
= function(mType){
                alert(color
+" "+name+" is runing("+mType+")");
            }

            
//priviledged method
            this.callRun = function(){
                
/*(1)priviledged method can visit private properties and private method*/
                run(type);
            }

        }


        Pet.prototype.callPrivateRun 
=function(pet){
        
/*(2)can not call run*/            
            
//pet.run2();
        /*(3)can call priviledge method and priviledge properties*/
            pet.callRun();
        }


        function test()
{
            var pet 
= new Pet("pig","black");
            pet.callRun();
            alert(
"prototype");
            pet.callPrivateRun(pet);

        }

        window.onload
=test;
    
</script>
繼承與覆寫
實例二演示了繼承、覆寫
另外javascript不支持多態性
<script>
        function Pet()
{
            
//name
            this.name=null;
            
this.getName = function() {return this.name;};
            
this.setName = function(newName) {this.name = newName;};
            
//abstract method
            this.eat = null;
        }

        
/*cat inherit from Pet*/
        Cat.prototype 
= new Pet();
        function Cat()
{
            
//implement the abstract method
            this.eat = function(food){
                alert(
"The cat (" + this.name+ ") is eating " + food);
            }

        }

        
/*dog inherit from Pet*/
        function Dog()
{
            
//implements the abstract method
            this.eat = function(food){
                alert(
"The dog (" + this.name+ ") is eating " + food);
            }

        }

        Dog.prototype 
= new Pet();
        
/*Hound inherit from dog*/
        Hound.prototype 
= new Dog()
        function Hound()
{
            
//override
            this.eat = function(food){
                alert(
"The Hound (" + this.name+ ") is eating " + food);
            }

        }


        function test()
{
            var cat 
= new Cat();
            cat.setName(
"mimi");
            cat.eat(
"fish");
            var dog 
= new Dog();
            dog.setName(
"wangwang");
            dog.eat(
"bone");
            var hound 
= new Hound();
            hound.setName(
"hali");
            hound.eat(
"rabbit");            
        }

        window.onload
=test;
    
</script>



dreamstone 2007-05-22 18:07 發表評論
]]>
在一個js文件中引入另一個js文件http://www.aygfsteel.com/dreamstone/archive/2007/02/12/99480.htmldreamstonedreamstoneMon, 12 Feb 2007 09:00:00 GMThttp://www.aygfsteel.com/dreamstone/archive/2007/02/12/99480.htmlhttp://www.aygfsteel.com/dreamstone/comments/99480.htmlhttp://www.aygfsteel.com/dreamstone/archive/2007/02/12/99480.html#Feedback4http://www.aygfsteel.com/dreamstone/comments/commentRss/99480.htmlhttp://www.aygfsteel.com/dreamstone/services/trackbacks/99480.html
function alertInOne(){
    alert(
'in one');
}

第二個js文件,文件名two.js,內容如下
//注意這個地方
document.write("<script language='javascript' src='one.js'></script>");
function alertInTwo()
{
    alert(
"in Two");
}

調用的html文件,只需要引入two.js,就能引入one.js了
<script language='javascript' src="two.js"></script>
<script language="javascript">
    alertInOne();
    alertInTwo();
</script>

應用場合:
在平時開發的時候,我們都會有一些js文件的積累,大部份場合是不需要重新寫的。
但我們會把js文件的功能盡可能的細分,以便引入的時候不引入無用的代碼,但這樣造成的問題是在jsp文件
中要寫大量的這樣的句子
<script language='javascript' src="two.js" charset="utf-8"></script>
如果你有100個jsp文件,都用到10個js文件,這個時候每個jsp文件寫10句引入,這個是個麻煩的事情
現在,通過js文件的引入可以解決這個問題。定義一個js文件用來引入一些組合,jsp文件則只需要引入1個
這樣的js文件就可以了。js代碼少了100*99行

另外引入的js文件時候最好加上charset,特別是你的js文件有非英文,數字的時候。
事例的代碼下載:http://www.aygfsteel.com/Files/dreamstone/importJs.rar



dreamstone 2007-02-12 17:00 發表評論
]]>
JavaScript中容易犯的小錯誤http://www.aygfsteel.com/dreamstone/archive/2006/12/06/85917.htmldreamstonedreamstoneWed, 06 Dec 2006 11:29:00 GMThttp://www.aygfsteel.com/dreamstone/archive/2006/12/06/85917.htmlhttp://www.aygfsteel.com/dreamstone/comments/85917.htmlhttp://www.aygfsteel.com/dreamstone/archive/2006/12/06/85917.html#Feedback1http://www.aygfsteel.com/dreamstone/comments/commentRss/85917.htmlhttp://www.aygfsteel.com/dreamstone/services/trackbacks/85917.html而這個函數的使用,本身隱藏著一個容易范的錯誤。請嘗試一下下邊這段代碼

alert(parseInt("8"));
alert(parseInt("08"));
會看到什么結果 ?
首先是8,然后是0,為什么parseInt("08")會是0呢 ?
原因如下:
js在默認情況下是用的10進制,但是如果以0開頭的數字,默認就會變成8進制
所以才會出現8,9錯誤的情況。
解決方案:
解決方法如下 parseInt("08",10);
指定為10進制。


dreamstone 2006-12-06 19:29 發表評論
]]>
Native2Ascii的JavaScript實現 (便于平時使用)http://www.aygfsteel.com/dreamstone/archive/2006/11/20/82185.htmldreamstonedreamstoneMon, 20 Nov 2006 02:46:00 GMThttp://www.aygfsteel.com/dreamstone/archive/2006/11/20/82185.htmlhttp://www.aygfsteel.com/dreamstone/comments/82185.htmlhttp://www.aygfsteel.com/dreamstone/archive/2006/11/20/82185.html#Feedback2http://www.aygfsteel.com/dreamstone/comments/commentRss/82185.htmlhttp://www.aygfsteel.com/dreamstone/services/trackbacks/82185.html閱讀全文

dreamstone 2006-11-20 10:46 發表評論
]]>
js判斷瀏覽器 http://www.aygfsteel.com/dreamstone/archive/2006/09/20/70911.htmldreamstonedreamstoneWed, 20 Sep 2006 13:22:00 GMThttp://www.aygfsteel.com/dreamstone/archive/2006/09/20/70911.htmlhttp://www.aygfsteel.com/dreamstone/comments/70911.htmlhttp://www.aygfsteel.com/dreamstone/archive/2006/09/20/70911.html#Feedback0http://www.aygfsteel.com/dreamstone/comments/commentRss/70911.htmlhttp://www.aygfsteel.com/dreamstone/services/trackbacks/70911.htmlfunction myconfirm(strTitle,strMessage,intType,intWidth,intHeight)
{
      var navigatorName = "Microsoft Internet Explorer";
   var isIE = false;
   var result;
   
   if( navigator.appName == navigatorName ){
    isIE = true;    
   }   
   
   if(isIE){    
     var strDialogFeatures = "status:no;center:yes;help:no;dialogWidth:"+intWidth+";dialogHeight:"+intHeight+";scroll:yes;resize:no";
     var args = new Array();
     args[args.length] = strTitle;
     args[args.length] = strMessage;
     args[args.length] = intType;
     result = showModalDialog("../confirm.html",args,strDialogFeatures);
     return result;
   }
   else{
    var messageList = strMessage.split("<BR>");
    var sMessage = "";
    
    for(loop=0;loop<messageList.length;loop++){
     sMessage = sMessage + messageList[loop] + "\n";
    }
    
    result = window.confirm(sMessage);
    return result;
   }
}


dreamstone 2006-09-20 21:22 發表評論
]]>
javascript 驗證web輸入地內容地長度 http://www.aygfsteel.com/dreamstone/archive/2006/09/20/70910.htmldreamstonedreamstoneWed, 20 Sep 2006 13:21:00 GMThttp://www.aygfsteel.com/dreamstone/archive/2006/09/20/70910.htmlhttp://www.aygfsteel.com/dreamstone/comments/70910.htmlhttp://www.aygfsteel.com/dreamstone/archive/2006/09/20/70910.html#Feedback0http://www.aygfsteel.com/dreamstone/comments/commentRss/70910.htmlhttp://www.aygfsteel.com/dreamstone/services/trackbacks/70910.html通常需要驗證一個textbox的輸入長度字母數字n或者漢字n/2個,但在混合的情況下不好判斷,使用如下方法判斷
function getStringUTFLength(str) {
  var value = str.replace(/[^\x00-\xff]/g,"  ");
  return value.length;
 }


dreamstone 2006-09-20 21:21 發表評論
]]>
主站蜘蛛池模板: 芦山县| 万源市| 勐海县| 大新县| 内黄县| 湖南省| 清流县| 留坝县| 辽中县| 宜丰县| 上犹县| 皮山县| 龙口市| 宿松县| 广德县| 华蓥市| 彭山县| 张家界市| 弥勒县| 隆安县| 繁昌县| 东山县| 石景山区| 临汾市| 白玉县| 罗源县| 措美县| 巴东县| 海门市| 大方县| 定远县| 高陵县| 方山县| 潍坊市| 九龙城区| 黑河市| 綦江县| 石阡县| 六枝特区| 黔南| 高淳县|