乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      JavaScript_summary2012年8月25日17:48:46

       昵稱2735774 2012-08-25

      <html>  <!-- -->
      <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
      <body>
      <!--<script language="javascript" type="text/javascript" src="yzj.js"></script>-->
      <script type="text/javascript">
      //基本數(shù)據(jù)類型共五種:即數(shù)值型、字符串型、布爾型、undefined、null
      //age=26;//變量未聲明直接賦值,為數(shù)值類型,為全局變量,整個HTML文檔的所有腳本都能訪問該變量
      //var username="yzj";//變量聲明并賦值,為字符串類型,局部變量是在函數(shù)內(nèi)聲明的變量
      //var marriaged;//聲明未賦值,默認(rèn)值為undefined
      //marriaged=true;//布爾型
      //數(shù)據(jù)類型的轉(zhuǎn)換
      //var a="100", b=50;
      //var c=a+b//【10050】b被隱式轉(zhuǎn)換為字符串型
      //var d=parseInt(a)+b;//【150】a被顯示轉(zhuǎn)換成數(shù)值型,parseInt將字符串轉(zhuǎn)換為整數(shù)


      //運算符,JavaScript中的運算符基本和java差不多,多了恒等于、非恒等于,但typeof相對于java中的instanceof
      //算術(shù)運算符+ - * / % ++ --,+還可以連接字符串,-可以為負(fù)號;關(guān)系運算符== != > < >= <= === !==
      //邏輯運算符 && || !  賦值運算符=  復(fù)合運算符  ?:運算符 ,逗號運算符
      //void運算符 未看
      //document.writeln("字符串類型:" + typeof a);//【string】number string boolean undefined 對象返回object 函數(shù)返回function
      //document.writeln("數(shù)值類型:" + typeof b);//【number】
      //document.writeln("等于==會發(fā)生自動類型轉(zhuǎn)換:" + (3 == "3"));//【true】
      //document.writeln("恒等于===不會發(fā)生自動類型轉(zhuǎn)換" + (3 === "3"));//【false】

      //流程控制,基本和java差不多,由于JavaScript是弱類型語言,所以switch語句中的表達(dá)式不限制類型,可以為數(shù)值型、字符串型、布爾型等
      //if switch where do...where for break continue
      /*var grade = prompt("please input your grade like: 及格 不及格", "不及格");
      switch(grade){
       case "及格"://可以直接對字符串進(jìn)行判斷
       alert("及格");
       break;
       case "不及格":
       alert("不及格");
       break;
       }
      */


      //函數(shù): 變量聲明以var開頭,函數(shù)聲明以function開頭;由于JavaScript是弱類型語言,所以函數(shù)有返回值,但聲明時無返回值類型;形參為局部變量,一般聲明時省略var;弱類型,所以不進(jìn)行參數(shù)類型和個數(shù)的檢查,需要自己通過typeof檢查類型,實參多余的參數(shù)會被省略,實參過少的參數(shù)會被賦值為undefined;
      //也分為值傳遞和引用傳遞
      //匿名函數(shù),即在表達(dá)式中定義函數(shù)var square=function(x){return x*x}  調(diào)用方式:square(3);
      //動態(tài)創(chuàng)建函數(shù) p71 未看
      //函數(shù)的嵌套 p72未看
      //遞歸函數(shù) p73 未看
      //arguments數(shù)組,用來存放傳入的實際參數(shù)值,可以直接使用該數(shù)組訪問實參
      /*function printArguments(){
        for(var i=0; i<arguments.length; i++){document.write("arguments[" + i + "] is: " + arguments[i] + "<br />");}
       }
       printArguments("arg1", "arg2");
       funcAsData=printArguments;//作為數(shù)據(jù)的函數(shù):函數(shù)可以像其他數(shù)據(jù)一樣賦值給變量、作為參數(shù)、作為元素保存在數(shù)組中
       alert("type of funcAsData is: " + typeof funcAsData);
       funcAsData("funcAsData para1","funcAsData para2", "funcAsData para3");//變量funcAsData變?yōu)楹瘮?shù)
      */ 
        
      //arguments對象的callee屬性 p76 未看
      //作為數(shù)據(jù)的函數(shù) 作為數(shù)據(jù)的函數(shù)是function類型 其typeof的值為function  p77 未實踐
      //內(nèi)置函數(shù):parseInt(numString)將字符串轉(zhuǎn)換為整數(shù),parseFloat(numString);isNaN(numValue)判斷制定的值是否為NaN,isFinite(numValue)判斷指定的值是否為有限的;eval(codeString)用于執(zhí)行JavaScript代碼,實現(xiàn)js代碼的動態(tài)執(zhí)行
      //escape()將字符串進(jìn)行Unicode編碼,unescape()與escape相反;encodeURI()將字符串編碼為統(tǒng)一資源標(biāo)識符,decodeURI()與encodeURI相反;
      //所有內(nèi)置函數(shù)Global對象的方法、Global對象用于存儲全局的屬性和方法,所有內(nèi)部對象的構(gòu)造函數(shù)都是Global的屬性,如NaN、Array


      //對象,對象分為內(nèi)部對象、宿主對象、自定義對象
      //內(nèi)部對象:Array Boolean Date Function Global Math Number Object RegExp String Error等,其中Global和Math對象在腳本初始化時就被創(chuàng)建,不需要實例化這兩個對象
      //宿主對象:JavaScript運行環(huán)境所提供的對象,如瀏覽器提供的對象稱為瀏覽器對象,如Window、Document

      //var date = new Date();//對象實例的創(chuàng)建
      /*function Person(){//自定義對象
       this.age=20;//加上this關(guān)鍵字為public對象,可以在對象外部被直接訪問,否則不能被直接訪問
       this.name="zhangsan";
       this.speak=function(){
        document.write(this.name + " is speaking!");
        }
       this.run=run;
       }
       function run(){
        document.write("run function");
        }
      var person = new Person();
      document.write("age is: " + person.age + "<br />");//如果age對象去掉this關(guān)鍵字,在此就不能被直接訪問,其值為undefined
      document.write("name is: " + person.name + "<br />");
      person.run();
      person.sex="male";//動態(tài)添加對象實例的屬性
      person.shout=function(){//動添加對象實例的方法
       document.write("<br />shout function<br />");
       }
      person.shout();  
      document.write("sex is: " + person.sex);
      //var person1 = new Person();
      //person1.shout();//出錯,shout方法只屬于person對象實例
      with(person){
       document.write("<br />with age is: " + age);//用with語句就能夠省去person前綴,簡化代碼輸入
       shout();
       }
       document.write("for in statement <br />");
      for(var variable in person){
       document.write(variable + " ");//【age name speak run sex shout 】,方法在對象中也是屬性
       document.write(person[variable] + " ");//此處必須用[]訪問屬性值,不能用person.variable 【函數(shù)輸出的結(jié)果為函數(shù)體,如function(){ document.write(this.name + " is speaking!"); }】
       }
      delete person.sex;//動態(tài)刪除對象實例的熟悉
      delete person.shout;//動態(tài)刪除對象實例的方法
      person=null;//將對象實例設(shè)置為null,釋放內(nèi)存空間*/

      /*var book={//創(chuàng)建無類型對象
       title:"talent yzj", //注意屬性與屬性值用":"隔開,屬性之間用","隔開
       introduce:function(){
        document.write("this book's title is: " + this.title);//此處title前一定要加this
        }
       }
      book.introduce();*/

      //obj.property=newValue;重定義屬性
      //obj.method=function(){}重定義方法
      //delete obj.property;刪除屬性
      //delete obj.method;刪除方法
      //obj=null; 對象的廢除


      //7.6 Function對象 未看


      //7.7 Object對象是所有對象的基礎(chǔ),即父類,其他方法都繼承了Object對象的屬性和方法
      /*
      var date = new Date();//constructor屬性用來引用構(gòu)造函數(shù)
      document.write("Date的構(gòu)造函數(shù)是: " + date.constructor); //【 function Date() { [native code] } 】
      if(date.constructor == Date){document.write("<br />date is an instance of Date<br />");}//【date is an instance of Date】
      document.write(new Date() + "<br />");//【Sat Aug 25 12:28:52 UTC+0800 2012】
      document.write(new Date().toString() + "<br />");//和上面顯示結(jié)果是一樣的,但最好用上toString()方法。在alert和document.write方法內(nèi)的對象會自動調(diào)用toString方法
      document.write(new Date().toLocaleString() + "<br />");//【2012年8月25日 12:28:52】
      //alueOf() 未實踐
      var obj = new Object();//利用Object對象創(chuàng)建自定義對象
      obj.age=20;
      obj.name="yzj";
      obj.printObj=function(){
       document.write("obj.age is: " + obj.age + "<br />" + "obj.name is: " + obj.name  + "<br />"); 
       }
      obj.printObj();//【obj.age is: 20   obj.name is: yzj】 
      var num = new Number(10);
      document.write("valueOf num is: " + num.valueOf() + "<br />" );//【valueOf num is: 10】
      */


      //數(shù)組:由于JavaScript是弱類型語言,所以同一個數(shù)組可以具有不同類型的數(shù)組元素
      /*
      var array1 = new Array();//創(chuàng)建空數(shù)組
      var array2 = new Array(10);//創(chuàng)建長度為10的數(shù)組
      var array3 = new Array("str",123,true,new Object);//創(chuàng)建擁有不同類型數(shù)據(jù)的長度為4的數(shù)組
      var array4 = [2012, false, "人生的意義有自己定義"];//使用[]創(chuàng)建數(shù)組
      with(document){
       write("array1: " + array1 + "<br />");//【js中遍歷數(shù)組還真簡單】
       write("array2: " + array2 + "<br />");//【,,,,,,,,,】
       write("array3: " + array3 + "<br />");//【str,123,true,[object Object]】
       write("array4: " + array4 + "<br />");//【2012,false,人生的意義有自己定義】
       }
      for(var i in array4){//用for in語句遍歷數(shù)組
       document.write("array4[" + i + "]" + array4[i] + "<br />");
       }
      array4[5]="array45"; //動態(tài)地修改數(shù)組大小,添加元素
      array4.length=10;//動態(tài)修改數(shù)組長度為10,array4[6]-array4[9]值為undefined
      document.write("array4[8] is : " + array4[8] + "<br />"); //【undefined】
      array4.length=3;//動態(tài)縮小數(shù)組長度為3,array4[5]將丟失
      document.write("array4[5] is : " + array4[5] + "<br />");//【undefined】
      document.write("array4.length is : " + array4.length + "<br />");//【3】
      var arrayConcat = array3.concat(array4);//concat合并數(shù)組
      document.write("arrayConcat.length is : " + arrayConcat.length + "<br />");//【7】
      var lenPush = array3.push(123,"456");//在數(shù)組末尾加入多個元素,返回加入后數(shù)組的長度
      document.write("array3.length is:" + array3.length + "<br />");//【6】
      var arrayPop = array3.pop();//刪除數(shù)組最后一個元素并返回該元素
      document.write("array3.length is:" + array3.length + "<br />");//【5】
      var arrayShift = array3.shift();//刪除第一個元素并返回該元素
      document.write("array3.length is:" + array3.length + "<br />");//【4】
      var lenUnshift = array3.unshift("unshift", 123);//在數(shù)組開頭插入多個元素,并返回插入后數(shù)組的長度
      document.write("array3.length is:" + array3.length + "<br />");//【6】
      */
      /*
      var spliceArray = new Array();//splice刪除并替換元素,用于插入、刪除或替換數(shù)組的元素。
      spliceArray.splice(0,0,1,2,3,4,5);//插入
      document.write(spliceArray + "<br />");//【1,2,3,4,5】
      spliceArray.splice(2,4,"a","b","c");//替換
      document.write(spliceArray + "<br />");//【1,2,a,b,c】
      spliceArray.splice(3,4);//刪除
      document.write(spliceArray + "<br />");//【1,2,a】
      document.write(spliceArray.join("-") + "<br />");//join以特定分隔把數(shù)組連接成字符串【1-2-a】
      spliceArray.reverse();//反轉(zhuǎn)數(shù)組
      document.write(spliceArray + "<br />");//【a,2,1】
      */
      //其他array方法:slice截取部分?jǐn)?shù)組元素、sort數(shù)組排序
      //多維數(shù)組 p130 未看


      //字符串對象
      //String.length 長度屬性、concat連接字符串、toUpperCase轉(zhuǎn)換成大寫、toLowerCase轉(zhuǎn)換成小寫、charAt指定位置的字符
      //index指定字符串中字符的索引、split分隔字符串、slice提取子字符串、substr從起始索引號提取字符串中指定數(shù)目的字符。
      //localeCompare 用本地特定的順序來比較兩個字符串  fromCharCode根據(jù)字符的Unicode編碼來生產(chǎn)字符串、向字符串中插入HTML標(biāo)記,如big、bold等


      //第十章 數(shù)學(xué)運算和日期時間 未看
      //第十一章 數(shù)值與異常處理 未看
      //第十二章 正則表達(dá)式 未看


      //第十二章 瀏覽器對象Browser Object
      //window對象的方法:alert、prompt、confirm等
      //13.3.1窗口及子窗口的打開與關(guān)閉 未實踐
      //window.open("subWindow.html","subWindow","status, menubar");
      //13.3.2 改變窗口位置和大小 13.3.3滾動窗口 13.3.5狀態(tài)欄 13.3.6定時設(shè)定  未看
      //13.3.4系統(tǒng)對話框 三種系統(tǒng)對話框:alert警告對話框、prompt輸入對話框和confirm確認(rèn)對話框(點確定返回true,點取消返回false)
      //if(confirm("are you an adult?")){alert("welcom to adult world!");}else{alert("you are not allowed to join in!");}

      //常用函數(shù)函數(shù)
      //document.write("" + "<br />"); 
      //var age1=prompt("please input your age: ", 0);//彈出對話框,接受用戶輸入的信息,第一個參數(shù)是提示文字、第二個參數(shù)為默認(rèn)值
      //alert("your age is: " + age1);


      //13.4 Navigator導(dǎo)航  保存當(dāng)前瀏覽器和操作系統(tǒng)資源的信息,如瀏覽器名字、操作系統(tǒng)版本、是否支持及開啟java等
      //13.5 History對象 保存瀏覽器的網(wǎng)頁歷史記錄信息 length歷史記錄中URL個數(shù)  back后退到上一頁面 forward前進(jìn)到下一頁面 go(num)跳到指定頁面
      //document.write("<a href=\"subWindow.html\">subWindow</a>");
      //document.write("<form><input name=\"\" type=\"button\" value=\"back\" onclick=\"window.history.back()\"></form>");//在subWindow文件中加入該句,點擊back按鈕就會回到當(dāng)前窗口
      //點擊forward按鈕就會回跳到subWindow窗口,也可以直接用history.forword(),因為history實例是Window對象的屬性
      //document.write("<form><input name=\"\" type=\"button\" value=\"forward\" onclick=\"window.history.forward()\"></form>");
      //13.6 Location 對象包含有關(guān)當(dāng)前 URL 的信息,如完整URL、端口號port、主機名hostname。Location 對象是 Window 對象的一個部分
      //,可通過 window.location 屬性來訪問??蓪崿F(xiàn)頁面的跳轉(zhuǎn)。
      /*
      <form> //錯誤,千萬別把HTML代碼放在JavaScript代碼段中運行,一定要注意這種小錯誤
      <input type="text" value=""  id="urlText" />
      <input type="button" value="轉(zhuǎn)到" onclick="window.location=document.forms[0].urlText.value"  />
      </form>
      */
      //235-238未看

      </script>
      <form>
        <input id="url" type="text" value="" />
        <input type="button" value="轉(zhuǎn)到" onclick="window.location=document.forms[0].url.value"/>//跳轉(zhuǎn)到輸入地址頁面
      </form>

      </body>


      </html>

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多