Time of Update: 2013-10-28
擷取頁面中元素到文檔地區document的橫向、縱向座標的兩種方法及其比較 在js控制元素運動的過程中,對於頁面元素座標位置的擷取是經常用到的,這裡主要總結下兩種方法: 一:通過疊加元素對象和它的offsetParent(如果存在)的offsetLeft/offsetTop屬性來實現 在閱讀javascript進階程式設計第三版DOM部分時,瞭解到要擷取某個元素在頁面上的位移量,需要將這個元素的offsetLeft和offsetTop與其offsetParent的相同屬性相
Time of Update: 2013-10-28
寫javascirpt代碼時,typeof和instanceof這兩個操作符時不時就會用到,堪稱必用。但是!使用它們總是不能直接的得到想要的結果,非常糾結,普遍的說法認為“這兩個操作符或許是javascript中最大的設計缺陷,因為幾乎不可能從他們那裡得到想要的結果” typeof 說明:typeof返回一個運算式的資料類型的字串,返回結果為js基本的資料類型,包括number,boolean,string,object,undefined,funct
Time of Update: 2013-10-28
js replace 與replaceall執行個體用法 stringObj.replace(rgExp, replaceText) 參數 stringObj 必選項。要執行該替換的 String 對象或字串文字。該字串不會被 replace 方法修改。 rgExp 必選項。為包含Regex模式或可用標誌的Regex對象。也可以是 String 對象或文字。如果 rgExp 不是Regex對象,它將被轉換為字串,並進行精確的尋找;不要嘗試將字串轉化為Regex。
Time of Update: 2013-10-28
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="
Time of Update: 2013-10-22
瀏覽器頁面地區大小的擷取: 複製代碼 代碼如下: //在IE、FireFox、Opera下都可以使用 document.body.clientWidth document.body.clientHeight //即可獲得,很簡單,很方便。 //而在公司項目當中: //Opera仍然使用 document.body.clientWidth document.body.clientHeight //可是IE和FireFox則使用
Time of Update: 2013-10-22
JQuery版 複製代碼 代碼如下: $.ajax({ url : "order/order_orderDetail.do?params.type=merge", type : "post", data : params, success : function(xml) { hide(); if(xml == ""){ Dialog.popTip("找不到需要合并的訂單", 2); }else{ var myTable=document.getElementById( "t_product" )
Time of Update: 2013-10-22
複製代碼 代碼如下: <!doctype html> <html> <head> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /> <title>Image preview example</title> <script type="text/javascript"> var loadImageFile =
Time of Update: 2013-10-22
複製代碼 代碼如下:jQuery.extend = jQuery.fn.extend = function() { var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i =
Time of Update: 2013-10-22
複製代碼 代碼如下: <asp:DropDownList ID="type1" runat="server" CssClass="tfont" onchange="link(this.id);" </asp:DropDownList> <%-- 大小類--%> <script> function link(id) { var obj = document.getElementById(id); var obj1 =
Time of Update: 2013-10-22
複製代碼 代碼如下: <!DOCTYPEhtml PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <hrad> <metahttp-equiv="content-type"content="text/html;charset=utf-8">
Time of Update: 2013-10-22
複製代碼 代碼如下: /*擷取標籤的文字*/ function getTextContent(element, preformatted) { if (!elementIsVisible(element)) return ''; if (element.nodeType == 3 /*Node.TEXT_NODE*/) { var text = element.data; if (!preformatted) { //text = text.replace(/\n|\r|\t/g, " ");
Time of Update: 2013-10-22
當選擇“女”時,顯示“美女、才女”;當選擇“男”時,隱藏 aspx 頁面內容: 複製代碼 代碼如下: <head runat="server"> <title>用RadioButten(或CheckBox)實現div的顯示與隱藏</title> <script type="text/javascript" language="javascript"> function show2() { if
Time of Update: 2013-10-22
廢話不多說,上代碼: 複製代碼 代碼如下: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gbk" /> <title></title> <script type="text/javascript"> /** * 只能輸入數字0-9 */ function kp(){
Time of Update: 2013-10-22
將一個字串(可以是中文,在產生二維碼圖片之前將中文轉碼)產生二維碼圖片,如果想要帶log的二維碼,可以在產生後的二維碼中間部位自己添加一個小log,log圖片不要太大,不然就掃描不出內容了。 複製代碼 代碼如下: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="js/jquery-1.8.3.js"
Time of Update: 2013-10-22
問題: 在用js動態建立html頁面時: 複製代碼 代碼如下: var tab = document.createElement("table"); tab.innerHTML += "<td>訂貨單號</td>"+ "<td>單據日期</td>"+ "<td>商品類型</td>"+ "<td>訂單屬性</td>"+ "<td>配貨次數</td>"+
Time of Update: 2013-10-22
js 複製代碼 代碼如下: var popupStatus = 0; //loading popup with jQuery magic! function loadPopup(){ //loads popup only if it is disabled if(popupStatus==0){ $("#backgroundPopup").css({ "opacity": "0.7" }); $("#backgroundPopup").fadeIn("slow");
Time of Update: 2013-10-22
方法一 【注】需把控制項的 CSS 的 position 屬性設定為 relative 或 absolute。 複製代碼 代碼如下: <script type="text/javascript" src="js/jquery-1.8.0.js"></script> <script language="javascript"> $(document).ready(function(){ $("#right1").click(function(){
Time of Update: 2013-10-22
基本動畫代碼:複製代碼 代碼如下:<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Hello World jQuery!</title><script type="text/javascript" src="jquery-1.3.2.min.js"></script><script type="text/javascript">$(document)
Time of Update: 2013-10-22
Even a task as simple as this can be complicated without jQuery at our disposal. In plain JavaScript, we could add the highlightedclass as shown in the following code snippet: 複製代碼 代碼如下: window.onload = function() { var divs =
Time of Update: 2013-10-22
今天開發過程中,突然遇到此奇葩問題,我之前以為是我js開啟模態表單傳遞的url參數有問題,我使用open沒問題。使用模態表單則會先彈出此錯誤然後再顯示新開啟的介面。網上查了許久,總結解決方案如下: 1. 可能與IE的某些外掛程式衝突。請把所有無關的IE附加元件全部禁用後嘗試 2. 引用了不存在的js檔案 3. 頁面的某些檔案在文檔模型還沒建立時就已經開始引用相關的節點 我最後是通過禁用了IE中的外掛程式才解決的。