• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            aslucky

            C++

             

            javascript 有時(shí)很好用

            javascript 有時(shí)很好用(轉(zhuǎn))

            注:頁面上元素name屬性和JavaScript引用的名稱必須一致包括大小寫
               否則會(huì)提示你一個(gè)錯(cuò)誤信息 "引用的元素為空或者不是對(duì)象"
            ---------------------------------------------------------------------

            對(duì)象屬性
            document.title             //設(shè)置文檔標(biāo)題等價(jià)于HTML的<title>標(biāo)簽
            document.bgColor           //設(shè)置頁面背景色
            document.fgColor           //設(shè)置前景色(文本顏色)
            document.linkColor         //未點(diǎn)擊過的鏈接顏色
            document.alinkColor        //激活鏈接(焦點(diǎn)在此鏈接上)的顏色
            document.vlinkColor        //已點(diǎn)擊過的鏈接顏色
            document.URL               //設(shè)置URL屬性從而在同一窗口打開另一網(wǎng)頁
            document.fileCreatedDate   //文件建立日期,只讀屬性
            document.fileModifiedDate  //文件修改日期,只讀屬性
            document.fileSize          //文件大小,只讀屬性
            document.cookie            //設(shè)置和讀出cookie
            document.charset           //設(shè)置字符集 簡體中文:gb2312
            ---------------------------------------------------------------------
            對(duì)象方法
            document.write()                  //動(dòng)態(tài)向頁面寫入內(nèi)容
            document.createElement(Tag)       //創(chuàng)建一個(gè)html標(biāo)簽對(duì)象
            document.getElementById(ID)       //獲得指定ID值的對(duì)象
            document.getElementsByName(Name)  //獲得指定Name值的對(duì)象
            ---------------------------------------------------------------------

            images集合(頁面中的圖象)

            a)通過集合引用
            document.images             //對(duì)應(yīng)頁面上的<img>標(biāo)簽
            document.images.length      //對(duì)應(yīng)頁面上<img>標(biāo)簽的個(gè)數(shù)
            document.images[0]          //第1個(gè)<img>標(biāo)簽           
            document.images[i]          //第i-1個(gè)<img>標(biāo)簽

            b)通過nane屬性直接引用
            <img name="oImage">
            document.images.oImage      //document.images.name屬性

            c)引用圖片的src屬性
            document.images.oImage.src  //document.images.name屬性.src

            d)創(chuàng)建一個(gè)圖象
            var oImage
            oImage = new Image()
            document.images.oImage.src="http://www.webjx.com/1.jpg"
            同時(shí)在頁面上建立一個(gè)<img>標(biāo)簽與之對(duì)應(yīng)就可以顯示

            <html>
            <img name=oImage>
            <script language="javascript">
               var oImage
               oImage = new Image()
               document.images.oImage.src="http://www.webjx.com/1.jpg"
            </script>
            </html>

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

            forms集合(頁面中的表單)

            a)通過集合引用
            document.forms                 //對(duì)應(yīng)頁面上的<form>標(biāo)簽
            document.forms.length          //對(duì)應(yīng)頁面上<form>標(biāo)簽的個(gè)數(shù)
            document.forms[0]              //第1個(gè)<form>標(biāo)簽
            document.forms[i]              //第i-1個(gè)<form>標(biāo)簽
            document.forms[i].length       //第i-1個(gè)<form>中的控件數(shù)
            document.forms[i].elements[j]  //第i-1個(gè)<form>中第j-1個(gè)控件

            b)通過標(biāo)簽name屬性直接引用
            <form name="Myform"><input name="myctrl"></form>
            document.Myform.myctrl         //document.表單名.控件名

            -----------------------------------------------------------------------
            <html>
            <!--Text控件相關(guān)Script-->
            <form name="Myform">
            <input type="text" name="oText">
            <input type="password" name="oPswd">
            <form>
            <script language="javascript">
            //獲取文本密碼框的值
            document.write(document.Myform.oText.value)
            document.write(document.Myform.oPswd.value)
            </script>
            </html>
            -----------------------------------------------------------------------
            <html>
            <!--Select控件相關(guān)Script-->
            <form name="Myform">
            <select name="oSelect">
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            </select>
            </form>

            <script language="javascript">
               //遍歷select控件的option項(xiàng)
               var length
               length=document.Myform.oSelect.length
               for(i=0;i<length;i++)
               document.write(document.Myform.oSelect[i].value)
            </script>

            <script language="javascript">
               //遍歷option項(xiàng)并且判斷某個(gè)option是否被選中
               for(i=0;i<document.Myform.oSelect.length;i++){
               if(document.Myform.oSelect[i].selected!=true)
               document.write(document.Myform.oSelect[i].value)
               else
               document.write("<font color=red>"+document.Myform.oSelect[i].value+"</font>")   
               }
            </script>

            <script language="javascript">
               //根據(jù)SelectedIndex打印出選中的option
               //(0到document.Myform.oSelect.length-1)
               i=document.Myform.oSelect.selectedIndex
               document.write(document.Myform.oSelect[i].value)
            </script>

            <script language="javascript">
               //動(dòng)態(tài)增加select控件的option項(xiàng)
               var oOption = document.createElement("OPTION");
               oOption.text="4";
               oOption.value="4";
               document.Myform.oSelect.add(oOption);
            </script>
            <html>
            -----------------------------------------------------------------------
            <Div id="oDiv">Text</Div>
            document.all.oDiv                       //引用圖層oDiv
            document.all.oDiv.style                 
            document.all.oDiv.style.display=""      //圖層設(shè)置為可視
            document.all.oDiv.style.display="none"  //圖層設(shè)置為隱藏
            /*document.all表示document中所有對(duì)象的集合
            只有ie支持此屬性,因此也用來判斷瀏覽器的種類*/
            click() 對(duì)象.click() 使對(duì)象被點(diǎn)擊。
            closed 對(duì)象.closed 對(duì)象窗口是否已關(guān)閉true/false
            clearTimeout(對(duì)象) 清除已設(shè)置的setTimeout對(duì)象
            clearInterval(對(duì)象) 清除已設(shè)置的setInterval對(duì)象
            confirm("提示信息") 彈出確認(rèn)框,確定返回true取消返回false
            cursor:樣式 更改鼠標(biāo)樣式 hand crosshair text wait help default auto e/s/w/n-resize

            event.clientX 返回最后一次點(diǎn)擊鼠標(biāo)X坐標(biāo)值;
            event.clientY 返回最后一次點(diǎn)擊鼠標(biāo)Y坐標(biāo)值;
            event.offsetX 返回當(dāng)前鼠標(biāo)懸停X坐標(biāo)值
            event.offsetY 返回當(dāng)前鼠標(biāo)懸停Y坐標(biāo)值

            document.write(document.lastModified) 網(wǎng)頁最后一次更新時(shí)間
            document.ondblclick=x 當(dāng)雙擊鼠標(biāo)產(chǎn)生事件
            document.onmousedown=x 單擊鼠標(biāo)鍵產(chǎn)生事件

            document.body.scrollTop; 返回和設(shè)置當(dāng)前豎向滾動(dòng)條的坐標(biāo)值,須與函數(shù)配合,
            document.body.scrollLeft; 返回和設(shè)置當(dāng)前橫向滾動(dòng)務(wù)的坐標(biāo)值,須與函數(shù)配合,
            document.title document.title="message"; 當(dāng)前窗口的標(biāo)題欄文字
            document.bgcolor document.bgcolor="顏色值"; 改變窗口背景顏色
            document.Fgcolor document.Fgcolor="顏色值"; 改變正文顏色
            document.linkcolor document.linkcolor="顏色值"; 改變超聯(lián)接顏色
            document.alinkcolor document.alinkcolor="顏色值"; 改變正點(diǎn)擊聯(lián)接的顏色
            document.VlinkColor document.VlinkColor="顏色值"; 改變已訪問聯(lián)接的顏色
            document.forms.length 返回當(dāng)前頁form表單數(shù)
            document.anchors.length 返回當(dāng)前頁錨的數(shù)量
            document.links.length 返回當(dāng)前頁聯(lián)接的數(shù)量
            document.onmousedown=x 單擊鼠標(biāo)觸發(fā)事件
            document.ondblclick=x 雙擊鼠標(biāo)觸發(fā)事件
            defaultStatus window.status=defaultStatus; 將狀態(tài)欄設(shè)置默認(rèn)顯示

            function function xx(){...} 定義函數(shù)
            isNumeric 判斷是否是數(shù)字
            innerHTML xx=對(duì)象.innerHTML 輸入某對(duì)象標(biāo)簽中的html源代碼
            innerText divid.innerText=xx 將以div定位以id命名的對(duì)象值設(shè)為XX

            location.reload(); 使本頁刷新,target可等于一個(gè)刷新的網(wǎng)頁

            Math.random() 隨機(jī)涵數(shù),只能是0到1之間的數(shù),如果要得到其它數(shù),可以為*10,再取整
            Math.floor(number) 將對(duì)象number轉(zhuǎn)為整數(shù),舍取所有小數(shù)
            Math.min(1,2) 返回1,2哪個(gè)小
            Math.max(1,2) 返回1,2哪個(gè)大

            navigator.appName 返回當(dāng)前瀏覽器名稱
            navigator.appVersion 返回當(dāng)前瀏覽器版本號(hào)
            navigator.appCodeName 返回當(dāng)前瀏覽器代碼名字
            navigator.userAgent 返回當(dāng)前瀏覽器用戶代標(biāo)志

            onsubmit onsubmit="return(xx())" 使用函數(shù)返回值
            opener opener.document.對(duì)象 控制原打開窗體對(duì)象

            prompt xx=window.prompt("提示信息","預(yù)定值"); 輸入語句
            parent parent.框架名.對(duì)象 控制框架頁面

            return return false 返回值
            random 隨機(jī)參數(shù)(0至1之間)
            reset() form.reset(); 使form表單內(nèi)的數(shù)據(jù)重置

            split("") string.split("") 將string對(duì)象字符以逗號(hào)隔開
            submit() form對(duì)象.submit() 使form對(duì)象提交數(shù)據(jù)

            String對(duì)象的 charAt(x)對(duì)象 反回指定對(duì)象的第多少位的字母
            lastIndexOf("string") 從右到左詢找指定字符,沒有返回-1
            indexOf("string") 從左到右詢找指定字符,沒有返回-1
            LowerCase() 將對(duì)象全部轉(zhuǎn)為小寫
            UpperCase() 將對(duì)象全部轉(zhuǎn)為大寫
            substring(0,5) string.substring(x,x) 返回對(duì)象中從0到5的字符
            setTimeout("function",time) 設(shè)置一個(gè)超時(shí)對(duì)象
            setInterval("function",time) 設(shè)置一個(gè)超時(shí)對(duì)象

            toLocaleString() x.toLocaleString() 從x時(shí)間對(duì)象中獲取時(shí)間,以字符串型式存在
            typeof(變量名) 檢查變量的類型,值有:String,Boolean,Object,Function,Underfined

            window.event.button==1/2/3 鼠標(biāo)鍵左鍵等于1右鍵等于2兩個(gè)鍵一起按為3
            window.screen.availWidth 返回當(dāng)前屏幕寬度(空白空間)
            window.screen.availHeight 返回當(dāng)前屏幕高度(空白空間)
            window.screen.width 返回當(dāng)前屏幕寬度(分辨率值)
            window.screen.height 返回當(dāng)前屏幕高度(分辨率值)
            window.document.body.offsetHeight; 返回當(dāng)前網(wǎng)頁高度
            window.document.body.offsetWidth; 返回當(dāng)前網(wǎng)頁寬度
            window.resizeTo(0,0) 將窗口設(shè)置寬高
            window.moveTo(0,0) 將窗口移到某位置
            window.focus() 使當(dāng)前窗口獲得焦點(diǎn)
            window.scroll(x,y) 窗口滾動(dòng)條坐標(biāo),y控制上下移動(dòng),須與函數(shù)配合
            window.open() window.open("地址","名稱","屬性")
            屬性:toolbar(工具欄),location(地址欄),directions,status(狀態(tài)欄),
            menubar(菜單欄),scrollbar(滾動(dòng)條),resizable(改變大小), width(寬),height(高),fullscreen(全 屏),scrollbars(全屏?xí)r無滾動(dòng)條無參 數(shù),channelmode(寬屏),left(打開窗口x坐標(biāo)),top(打開窗口y坐標(biāo))
            window.location = 'view-source:' + window.location.href 應(yīng)用事件查看網(wǎng)頁源代碼;

            a=new Date(); //創(chuàng)建a為一個(gè)新的時(shí)期對(duì)象
            y=a.getYear(); //y的值為從對(duì)象a中獲取年份值 兩位數(shù)年份
            y1=a.getFullYear(); //獲取全年份數(shù) 四位數(shù)年份
            m=a.getMonth(); //獲取月份值
            d=a.getDate(); //獲取日期值
            d1=a.getDay(); //獲取當(dāng)前星期值
            h=a.getHours(); //獲取當(dāng)前小時(shí)數(shù)
            m1=a.getMinutes(); //獲取當(dāng)前分鐘數(shù)
            s=a.getSeconds(); //獲取當(dāng)前秒鐘數(shù)

            對(duì)象.style.fontSize="文字大小";
            單位:mm/cm/in英寸/pc帕/pt點(diǎn)/px象素/em文字高
            1in=1.25cm
            1pc=12pt
            1pt=1.2px(800*600分辯率下)

            文本字體屬性:
            fontSize大小
            family字體
            color顏色
            fontStyle風(fēng)格,取值為normal一般,italic斜體,oblique斜體且加粗
            fontWeight加粗,取值為100到900不等,900最粗,light,normal,bold
            letterSpacing間距,更改文字間距離,取值為,1pt,10px,1cm
            textDecoration:文字修飾;取值,none不修飾,underline下劃線,overline上劃線
            background:文字背景顏色,
            backgroundImage:背景圖片,取值為圖片的插入路徑

            點(diǎn)擊網(wǎng)頁正文函數(shù)調(diào)用觸發(fā)器:

            1.onClick 當(dāng)對(duì)象被點(diǎn)擊
            2.onLoad 當(dāng)網(wǎng)頁打開,只能書寫在body中
            3.onUnload 當(dāng)網(wǎng)頁關(guān)閉或離開時(shí),只能書寫在body中
            4.onmouseover 當(dāng)鼠標(biāo)懸于其上時(shí)
            5.onmouseout 當(dāng)鼠標(biāo)離開對(duì)象時(shí)
            6.onmouseup 當(dāng)鼠標(biāo)松開
            7.onmousedown 當(dāng)鼠標(biāo)按下鍵
            8.onFocus 當(dāng)對(duì)象獲取焦點(diǎn)時(shí)
            9.onSelect 當(dāng)對(duì)象的文本被選中時(shí)
            10.onChange 當(dāng)對(duì)象的內(nèi)容被改變
            11.onBlur 當(dāng)對(duì)象失去焦點(diǎn)
            onsubmit=return(ss())表單調(diào)用時(shí)返回的值

            直線 border-bottom:1x solid black
            虛線 border-bottom:1x dotted black
            點(diǎn)劃線 border-bottom:2x dashed black
            雙線 border-bottom:5x double black
            槽狀 border-bottom:1x groove black
            脊?fàn)?nbsp;border-bottom:1x ridge black

            1.邊緣高光glow(color=顏色,strength=亮光大小)

            posted on 2008-08-25 15:42 aslucky 閱讀(268) 評(píng)論(0)  編輯 收藏 引用 所屬分類: web

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            留言簿(1)

            隨筆分類(6)

            隨筆檔案(6)

            文章分類(2)

            文章檔案(2)

            Open source library

            Software often use

            搜索

            積分與排名

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            久久精品成人欧美大片| 久久综合亚洲色HEZYO国产| 久久久久无码精品国产| 国内精品久久久久久野外| 久久毛片免费看一区二区三区| 一本色道久久综合| 久久美女网站免费| 囯产极品美女高潮无套久久久 | 99久久99久久久精品齐齐| 精品久久777| 亚洲色大成网站WWW久久九九| 蜜桃麻豆www久久| 7777久久久国产精品消防器材| 国内精品欧美久久精品| 99久久精品国内| 亚洲AV无码成人网站久久精品大| 久久青青草原精品国产软件| 久久久亚洲欧洲日产国码二区 | 久久久国产精华液| 国内精品久久久久久麻豆| 97精品国产91久久久久久| 久久精品国产99国产精品亚洲| 人妻无码精品久久亚瑟影视| 精品久久久久中文字幕日本| 久久久久久久波多野结衣高潮| 久久天天躁狠狠躁夜夜不卡| 91精品婷婷国产综合久久| 国产成人久久精品激情| 久久精品夜夜夜夜夜久久| 亚洲va中文字幕无码久久不卡 | 久久国产精品99国产精| 久久精品青青草原伊人| 国产精品美女久久福利网站| 久久久精品人妻无码专区不卡| 国产精品丝袜久久久久久不卡| 51久久夜色精品国产| 久久99国产精品久久| 狠狠色综合久久久久尤物| 久久国产三级无码一区二区| 久久性精品| 久久久精品2019免费观看|