標籤:style blog http io ar color os 使用 sp
jquery 、 JS 指令碼參數的認識與使用
如何使用jquery重新整理當前頁面
下面介紹全頁面重新整理方法:有時候可能會用到
1 window.location.reload(); //重新整理當前頁面.2 3 parent.location.reload(); //重新整理父親對象(用於架構)4 5 opener.location.reload(); //重新整理父視窗對象(用於單開視窗)6 7 top.location.reload(); //重新整理最頂端對象(用於多開視窗)
下面再介紹一些javascript基本函數
1 document.write(”");為 輸出語句 2 js中的注釋為// 3 4 傳統的html文檔順序是:document->html->(head,body) 5 6 一個瀏覽器視窗中的dom順序是:window->(navigator,screen,history,location,document) 7 得到表單中元素的名稱和值:document.getelementbyid(”表單中元素的id號”).name(或value) 8 一個小寫轉大寫的js: document.getelementbyid(”output”).value = document.getelementbyid(”input”).value.touppercase(); 9 js中的實值型別:string,number,boolean,null,object,function 10 js中的字元型轉換成數值型:parseint(),parsefloat() 11 12 js中的數字轉換成字元型:(”"+變數) 13 14 js中的取字串長度是:(length) 15 16 js中的字元與字元相串連使用+號. 17 18 js中的比較操作符有:==等於,!=不等於,>,>=,<.<= 19 20 js中聲明變數使用:var來進行聲明 21 22 js中的判斷語句結構:if(condition){}else{} 23 24 js中的迴圈結構:for([initial expression];[condition];[upadte expression]) {inside loop} 25 26 迴圈中止的命令是:break 27 28 js中的函數定義:function functionname([parameter],…){statement[s]} 29 30 當檔案中出現多個form表單時.可以用document.forms[0],document.forms[1]來代替. 31 32 視窗:開啟視窗window.open(), 關閉一個視窗:window.close(), 視窗本身:self 33 34 狀態列的設定:window.status=”字元”; 35 36 彈出提示資訊:window.alert(”字元”); 37 38 彈出確認框:window.confirm(); 39 40 彈出輸入提示框:window.prompt(); 41 42 指定當前顯示連結的位置:window.location.href=”url” 43 44 取出表單中的所有表單的數量:document.forms.length 45 46 關閉文檔的輸出資料流:document.close(); 47 48 字串追加串連符:+= 49 50 建立一個文件項目:document.createelement(),document.createtextnode() 51 52 得到元素的方法:document.getelementbyid() 53 54 引用一個檔案式的js:<script type=”text/javascript” src=”aaa.js”></script> 55 56 指定在不支援指令碼的瀏覽器顯示的html:<noscript></noscript> 57 58 當超鏈和onclick事件都有時,則老版本的瀏覽器轉向a.html,否則轉向b.html.例:<a href=”a.html” onclick=”location.href=’b.html’;return false”>dfsadf</a> 59 60 js 的內建對象 有:array,boolean,date,error,evalerror,function,math,number,object,rangeerror,referenceerror,regexp,string,syntaxerror,typeerror,urierror 61 62 js中的換行:/n 63 64 視窗全屏大小:<script>function fullscreen(){ this.moveto(0,0);this.outerwidth=screen.availwidth;this.outerheight=screen.availheight;}window.maximize=fullscreen;</script> 65 66 js中的all代表其下層的全部元素 67 68 js中的焦點順序:document.getelementbyid(”表單元素”).tabindex = 1 69 70 innerhtml的值是表單元素的值:如how are you,則innerhtml的值就是:how are you 71 72 innertext的值和上面的一樣,只不過不會把em這種標記顯示出來. 73 74 contenteditable可設定元素是否可被修改,iscontenteditable返回是否可修改的狀態. 75 76 isdisabled判斷是否為禁止狀態.disabled設定禁止狀態 77 78 length取得長度,返回整型數值 79 80 addbehavior()是一種js調用的外部函數檔案其副檔名為.htc 81 82 window.focus()使當前的視窗在所有視窗之前. 83 84 blur()指失去焦點.與focus()相反. 85 86 select()指元素為選中狀態. 87 88 防止使用者對文字框中輸入文本:onfocus=”this.blur()” 89 90 取出該元素在頁面中出現的數量:document.all.tags(”div(或其它html標記符)”).length 91 92 js中分為兩種表單輸出:模態和非模態.window.showmodaldialog(),window.showmodeless() 93 94 狀態列文字的設定:window.status=‘文字’,預設的狀態列文字設定:window.defaultstatus = ‘文字.’; 95 96 添加到收藏夾:external.addfavorite(”http://www.google.com”,”google”); 97 98 js中遇到指令碼錯誤時不做任何操作:window.onerror = donothing; 指定錯誤控制代碼的文法為:window.onerror = handleerror; 99 100 js中指定當前開啟視窗的父視窗:window.opener,支援opener.opener…的多重繼續. 101 102 js中的self指的是當前的視窗 103 104 js中狀態列顯示內容:window.status=”內容” 105 106 js中的top指的是框架組中最頂層的架構 107 108 js中關閉當前的視窗:window.close(); 109 110 js中提出是否確認的框:if(confirm(”are you sure?”)){alert(”ok”);}else{alert(”not ok”);} 111 112 js中的視窗重新導向:window.navigate(”http://www.google.com”); 113 114 .js中的列印:window.print() 115 116 js中的提示輸入框:window.prompt(”message”,”defaultreply”); 117 118 js中的視窗捲軸:window.scroll(x,y) 119 120 js中的視窗滾動到位置:window.scrollby 121 122 js中設定時間間隔:setinterval(”expr”,msecdelay)或setinterval(funcref,msecdelay)或settimeout 123 124 js中的模態顯示在ie4+行,在nn中不行:showmodaldialog(”url”[,arguments][,features]); 125 126 js中的退出之前使用的控制代碼:function verifyclose(){event.returnvalue=”we really like you and hope you will stay longer.”;}} window.onbeforeunload=verifyclose; 127 128 當表單第一次調用時使用的檔案控制代碼:onload() 129 130 當表單關閉時調用的檔案控制代碼:onunload() 131 132 window.location的屬性: protocol(http:),hostname(www.example.com),port(80),host(www.example.com:80),pathname(”/a/a.html”),hash(”#giantgizmo”,指跳轉到相應的錨記),href(全部的資訊) 133 134 window.location.reload()重新整理當前頁面. 135 136 parent.location.reload()重新整理父親對象(用於架構) 137 138 opener.location.reload()重新整理父視窗對象(用於單開視窗) 139 140 top.location.reload()重新整理最頂端對象(用於多開視窗) 141 142 window.history.back()返回上一頁,window.history.forward()返回下一頁,window.history.go(返回第幾頁,也可以使用訪問過的url) 143 144 document.write()不換行的輸出,document.writeln()換行輸出 145 146 document.body.nowrap=true;防止連結文字折行. 147 148 變數名.charat(第幾位),取該變數的第幾位的字元. 149 150 ”abc”.charcodeat(第幾個),返回第幾個字元的ascii碼值. 151 152 字串串連:string.concat(string2),或用+=進行串連 153 154 .變數.indexof(”字元”,起始位置),返回第一個出現的位置(從0開始計算) 155 156 string.lastindexof(searchstring[,startindex])最後一次出現的位置. 157 158 string.match(regexpression),判斷字元是否匹配. 159 160 string.replace(regexpression,replacestring)替換現有字串. 161 162 string.split(分隔字元)返回一個數組儲存值. 163 164 string.substr(start[,length])取從第幾位到指定長度的字串. 165 166 string.tolowercase()使字串全部變為小寫.167 168 string.touppercase()使全部字元變為大寫. 169 170 parseint(string[,radix(代表進位)])強制轉換成整型.171 172 parsefloat(string[,radix])強制轉換成浮點型173 174 isnan(變數):測試是否為數值型. 175 176 定義常量的關鍵字:const,定義變數的關鍵字:var
本帖來自 http://www.51-sheji.com/article-74.html
jquery 、 JS 指令碼參數的認識與使用