軟件藝術思考者  
          混沌,彷徨,立志,蓄勢...
          公告
          日歷
          <2025年5月>
          27282930123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          導航

          隨筆分類(86)

          隨筆檔案(85)

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

           

          1.一個日歷插件。
          <script>
          /* Creation date: 2004-6-13 */
          var myC_x,myC_y;
          var myC_timeset=null,myC_timeset1=null;
          var divObj=null;
          var inputName;
          function myCalendar() //構建對象
          {
          var myDate = new Date();
          this.year = myDate.getFullYear();
          this.month = myDate.getMonth()+1;
          this.date = myDate.getDate();
          this.format="yyyy-mm-dd";
          this.style = myStyle(1); 
          this.show = createCalendar;
          this.input = createInput;
          }
          function myStyle(num) //設置樣式
          {
          if(!num||isNaN(num)){alert('參數不對,采用默認樣式!');num=1;}
           var style = new Array();
          style[1]=".week{background-color:#DfDfff;font-size:12px;width:140px;}"
          +".ds{width:140px;font-size:12px;cursor:hand}"
          +".mover{border:1px solid black;background-color:#f4f4f4;}"
          +".move1{border:1px solid #5d5d5d;background-color:#f4f4f4;color:#909eff;font-size:12px}"
          +".tit{background-color:#909EFF;width:140px;font-size:12px;color:white;cursor:default}"
          +".cs{position:absolute;border:1px solid #909eff;width:142px;left:0px;top:0px;z-index:9999;}"
          +".shadow{position:absolute;left:0px;top:0px;font-family: Arial Black;font-size:50px;color:#d4d4d4;z-index:1;text-align:center;}";
          document.write("<style type='text/css'>");
          document.write(style[num]);
          document.write("</style>");
          }
          function createCalendar()
          {
          var week = new Array('日','一','二','三','四','五','六');
          document.write("<div class='cs' onselectstart='return false' oncontextmenu='return false' onmousedown='if(event.button==2)this.style.display=\"none\"' id='myC_div'><div class='shadow'></div><div style='position:absolute;left:0px;top:0px;z-index:1'>");
          //創建頭部
          document.write("<table class='tit' id='myC_Top' onmousedown='myC_x=event.x-parentNode.parentNode.style.pixelLeft;myC_y=event.y-parentNode.parentNode.style.pixelTop;setCapture()' onmouseup='releaseCapture();' onmousemove='myCMove(this.parentElement.parentElement);'><tr><td width=10 onmouseover='this.style.color=\"black\"' onmouseout='this.style.color=\"\"' onclick='cutYear()' style='font-family: Webdings;cursor:hand;' title='減少年份'>7</td><td title='減少月份' onmouseover='this.style.color=\"black\"' onclick='cutMonth()' onmouseout='this.style.color=\"\"' width=10 style='font-family: Webdings;cursor:hand;'>3</td><td align=center onmouseover=this.className='move1'; onmouseout=this.className='';divHidden(myC.parentElement.nextSibling); onclick='createyear("+this.year+",this);divShow(myC.parentElement.nextSibling);'></td><td align=center onclick='createmonth("+this.month+",this);divShow(myC.parentElement.nextSibling)' onmouseover=this.className='move1'; onmouseout=this.className='';divHidden(myC.parentElement.nextSibling);></td><td width=10 onmouseover='this.style.color=\"black\"' onmouseout='this.style.color=\"\"' onclick='addMonth()' style='font-family: Webdings;cursor:hand;' title='增加月份'>4</td><td width=10 style='font-family: Webdings;cursor:hand;' onmouseover='this.style.color=\"black\"' onmouseout='this.style.color=\"\"' onclick='addYear()' title='增加年份'>8</td></tr></table>");
          //創建星期條目
          document.write("<table class='week'><tr>");
          for(i=0;i<7;i++)
          document.write("<td align=center>"+week[i]+"</td>");
          document.write("</tr></table>");
          //創建日期條目
          document.write("<table class='ds' id='myC' cellspacing=2 cellpadding=0>");
          for(i=0;i<6;i++)
          {
          document.write("<tr>");
          for(j=0;j<7;j++)
          document.write("<td width=10% height=16 align=center onmouseover='mOver(this)' onmouseout='mOut(this)' onclick='if(this.innerText!=\"\")getValue(inputName,this.innerText);myC_div.style.display=\"none\"'></td>");
          document.write("</tr>");
          }
          document.write("</table>");
          //建建水印
          document.write("</div>");
          //創建選擇圖層
          document.write("<div style='position:absolute;left:0px;top:0px;z-index:3' onmouseover=divShow(this) onmouseout=divHidden(this)></div>");
          document.write("</div>");
          //顯示日期
          showDate(this.year,this.month);
          myC_div.style.display='none';
          }
          function getValue(obj,value)
          {
          eval(obj).value=parseInt(myC_Top.cells[2].innerText)+"-"+parseInt(myC_Top.cells[3].innerText)+"-"+value;
          }
          function showDate(year,month)
          {
          var myDate = new Date(year,month-1,1);
          var today = new Date();
          var day = myDate.getDay();
          var length = new Array(31,30,31,30,31,30,31,31,30,31,30,31);
          length[1] = ((year%4==0)&&(year%100!=0)||(year%400==0))?29:28;
          for(i=0;i<myC.cells.length;i++)myC.cells[i].innerHTML = "";
          for(i=0;i<length[month-1];i++)
          {
          myC.cells[i+day].innerHTML = (i+1);
          if(new Date(year,month-1,i+1).getDay()==6||new Date(year,month-1,i+1).getDay()==0){myC.cells[i+day].style.color='red';}
          }
          myC_Top.cells[2].innerText=year+"年";
          myC_Top.cells[3].innerText=month+"月";
          with(myC.parentNode.previousSibling.style)
          {
          pixelLeft=myC.offsetLeft;
          pixelTop=myC.offsetTop;
          height = myC.clientHeight;
          width = myC.clientWidth;
          }
          myC.parentElement.parentElement.style.height=myC.parentElement.offsetHeight;
          myC.parentElement.previousSibling.innerHTML=year;
          }
          //一些附加函數--------------------
          //---------Begin-------------------
          function mOver(obj){obj.className = 'mover';}
          function mOut(obj){if(obj.className=='mover')obj.className = '';}
          function addYear(){var year = parseInt(myC_Top.cells[2].innerText);var month = parseInt(myC_Top.cells[3].innerText); year++;showDate(year,month);}
          function addMonth(){var year = parseInt(myC_Top.cells[2].innerText);var month = parseInt(myC_Top.cells[3].innerText);month++;if(month>12){month=1;year++;}showDate(year,month);}
          function cutYear(){var year = parseInt(myC_Top.cells[2].innerText);var month = parseInt(myC_Top.cells[3].innerText);year--;showDate(year,month);}
          function cutMonth(){var year = parseInt(myC_Top.cells[2].innerText);var month = parseInt(myC_Top.cells[3].innerText);month--;if(month<1){month=12;year--;}showDate(year,month);}
          function divS(obj)
          {
          if(obj!=divObj)
          {
          obj.style.backgroundColor="#909eff";
          obj.style.color='black';
          }
          if(divObj!=null)
          {
          divObj.style.backgroundColor='';
          divObj.style.color='';
          }
          divObj = obj;
          }
          function divShow(obj)
          { if (myC_timeset!=null) clearTimeout(myC_timeset);
          obj.style.display='block';
          }
          function divHidden(obj){myC_timeset=window.setTimeout(function(){obj.style.display='none'},500);}
          function createyear(year,obj)//創建年份選擇
          {
          var ystr;
          var oDiv;
          ystr="<table class='move1' cellspacing=0 cellpadding=2 width="+obj.offsetWidth+">";
          ystr+="<tr><td style='cursor:hand' onclick='createyear("+(year-20)+",myC_Top.cells[2])' align=center>上翻</td></tr>";
          for(i=year-10;i<year+10;i++)
          if(year==i)
          ystr+="<tr style='background-color:#909eff'><td style='color:black;height:16px;cursor:hand' align=center onclick='myC_Top.cells[2].innerText=this.innerText;showDate("+i+",parseInt(myC_Top.cells[3].innerText));myC.parentElement.nextSibling.innerHTML=\"\"'>"+i+"年</td></tr>";
          else
          ystr+="<tr><td align=center style='cursor:hand' onmouseover=divS(this) onclick='myC_Top.cells[2].innerText=this.innerText;showDate("+i+",parseInt(myC_Top.cells[3].innerText));myC.parentElement.nextSibling.innerHTML=\"\"'>"+i+"年</td></tr>";
          ystr+="<tr><td style='cursor:hand' onclick='createyear("+(year+20)+",myC_Top.cells[2])' align=center>下翻</td></tr>";
          ystr+="</table>";
          oDiv = myC.parentElement.nextSibling;
          oDiv.innerHTML='';
          oDiv.innerHTML = ystr;
          showDiv(oDiv,obj.offsetTop+obj.offsetHeight,obj.offsetLeft);
          }
          function createmonth(month,obj)//創建月份選擇
          {
          var mstr;
          var oDiv;
          mstr="<table class='move1' cellspacing=0 cellpadding=2 width="+(obj.offsetWidth+5)+">";
          for(i=1;i<13;i++)
          if (month==i)
          mstr+="<tr style='background-color:#909eff'><td style='color:black;height:16px;cursor:hand' align=center onclick='myC_Top.cells[3].innerText=this.innerText;showDate(parseInt(myC_Top.cells[2].innerText),"+i+");myC.parentElement.nextSibling.innerHTML=\"\"'>"+i+"月</td></tr>";
          else
          mstr+="<tr><td align=center style='cursor:hand' onmouseover='divS(this)' onclick='myC_Top.cells[3].innerText=this.innerText;showDate(parseInt(myC_Top.cells[2].innerText),"+i+");myC.parentElement.nextSibling.innerHTML=\"\"'>"+i+"月</td></tr>";
          mstr+="</table>";
          oDiv = myC.parentElement.nextSibling;
          oDiv.innerHTML='';
          oDiv.innerHTML = mstr;
          showDiv(oDiv,obj.offsetTop+obj.offsetHeight,obj.offsetLeft);
          }
          function showDiv(obj,top,left)
          {
          obj.style.pixelTop=top;
          obj.style.pixelLeft=left;
          }
          function myCMove(obj)
          {
          if(event.button==1)
          {
          var X = obj.clientLeft;
          var Y = obj.clientTop;
          obj.style.pixelLeft= X+(event.x-myC_x);
          obj.style.pixelTop= Y+(event.y-myC_y);
          window.status=myC_y;
          }
          }
          function showDiv2(obj)
          {
          inputName=obj.name;
          var e=obj;
          var ot = obj.offsetTop;
          var ol=obj.offsetLeft;
          while(obj=obj.parentElement){ot+=obj.offsetTop;ol+=obj.offsetLeft;}
          myC_div.style.pixelTop=ot+e.offsetHeight;
          myC_div.style.pixelLeft=ol;
          myC_div.style.display="block";
          }
          function createInput(name)
          {myC_div.style.display='none';
          document.write("<input type='text' name='"+name+"' size=20 onfocus='showDiv2(this)'>");
          }
          // --------------End ---------------------
          </script>
          <script>
          var myCalendar=new myCalendar;
          myCalendar.year=2006;
          myCalendar.show();
          myCalendar.input("txt1");
          </script>
          <input type="text" name="test" onfocus="showDiv2(this)" readonly=true>
          2.無刷新排序簡例
          <html>
          <head>
          <script>
          function order()
          {
          var it=event.srcElement;
          var table=it;
          var i,j,k;
          var t1,t2;
          if(it.tagName=="TH"){
          ??? i=it.cellIndex;
          ??? it.title=it.title=="asc"?"desc":"asc";
          ??? while(table.tagName!="TABLE")table=table.parentElement;
          ??? if(table.rows.length<3)return true;
          ??? for(j=1;j<table.rows.length;j++){
          ??????? for(k=j+1;k<table.rows.length;k++){
          ??????????? if(it.title=="asc"?parseFloat(table.rows[k].cells[i].innerText)<parseFloat(table.rows[j].cells[i].innerText):parseFloat(table.rows[k].cells[i].innerText)>parseFloat(table.rows[j].cells[i].innerText))
          ??????????? table.rows[j].swapNode(table.rows[k]);
          ??????? }
          ??? }
          }
          }
          </script>
          </head>
          <body>

          <table border="1">
          <thead onclick="order()" style="cursor:hand;">
          <th>Item 1</th><th>Item 2</th><th>Item 3</th><th>Item 4</th>
          </thead>
          <tr><td>12.3</td><td>423</td><td>86.83</td><td>1.213</td></tr>
          <tr><td>2</td><td>434</td><td>5.334</td><td>.234</td></tr>
          <tr><td>33</td><td>43</td><td>5.223</td><td>8.73</td></tr>
          <tr><td>21.3</td><td>234</td><td>52.34</td><td>.666</td></tr>
          <tr><td>33.4</td><td>59</td><td>67.2</td><td>.426</td></tr>
          </table>

          </body>
          </html>

          ?

          posted on 2006-12-08 11:49 智者無疆 閱讀(380) 評論(7)  編輯  收藏 所屬分類: Client teachnolgy research
          評論:
          • # 關于XHTML  self Posted @ 2006-12-12 15:13
              因為XHTML是XML的一個應用,一些在基于SGML的HTML 4中完全合法的習慣在XHTML中必須改變。

              文檔必須是編排良好的

              編排良好性Well-formedness是[XML]引入的一個新概念。從本質上說,這意味著元素必須有結束標簽,或者必須以特殊方式書寫(在下面說明)。

              元素必須嵌套,盡管SGML規定層疊非法,但現有的瀏覽器普遍允許層疊。

              正確:嵌套元素。

            <p>here is an emphasized <em>paragraph</em>.</p>

              不正確:層疊元素。

            <p>here is an emphasized <em>paragraph.</p></em>

              元素和屬性名必須小寫

              對所有HTML元素和屬性名,XHTML 文檔必須使用小寫。 因為XML是大小寫敏感的,所以這個差別是必須的。如 <li> 和 <LI> 是不同的標簽。

              對非空元素,必須使用結束標簽

              在基于 SGML的 HTML 4 中,一些隱含結束意義的元素允許忽略結束標簽。而在基于XML的XHTML中,這種忽略不被允許。除了在DTD中被聲明為空的元素,所有元素必須有結束標簽。

              正確:結束了的元素。

            <p>here is a paragraph.</p><p>here is another paragraph.</p>

              不正確:未結束元素。

            <p>here is a paragraph.<p>here is another paragraph.

              屬性值必須在引號中

              所有的屬性必須用引號,即使是數字。

              正確:在引號中的屬性值

            <table rows="3">

              不正確:不在引號中的屬性值。

            <table rows=3>

              屬性最小化

              XML 不支持屬性最小化. 屬性值對必須寫全。象compact,checked這樣的屬性名不能不指定屬性值而在元素中出現。

              正確:沒有最小化的屬性

            <dl compact="compact">

              不正確:最小化屬性

            <dl compact>

              空元素

              空元素要么必須有結束標簽,要么起始標簽以/>結束. 例如,<br/>或<hr></hr>. 請參看HTML兼容性指導 HTML Compatibility Guidelines 中的信息,以保證向后兼容HTML 4用戶代理程序

              正確:結束的空元素

            <br/><hr/>

              錯誤:未結束的空標簽

            <br><hr>

              屬性值中的空白字符處理

              對屬性值,用戶代理程序將刪去引導和后序空白符,將一個或多個空白符(包括換行)轉換成單個字符間空間(在西方書寫體中是一個ASCII空格) See Section 3.3.3 of [XML]。

              Script and Style 元素

              在XHTML中,script和style元素聲明為#PCDATA內容形式,因此,< 和 & 被看作是標識的開始,&lt和&amp 這樣的實體被XML處理程序看作為實體引用而分別被認為是< 和 & . 將script和style元素的內容包裹在CDATA記號部分中避免了這些實體的擴張。

            <script>
            <![CDATA[
            ... unescaped script content ...
            ]]>
            </script>

              CDATA 部分被 XML 處理程序識別,是文檔對象模型中一個結點。請參看1.3節Section 1.3的DOM LEVEL 1推薦標準[DOM]。

              替代的方式是使用外部script和style文檔。

              SGML 禁止

              SGML 給作者的DTD可以指定在一個元素內部禁止出現的元素。這樣的禁止在XML中是不可能的。

              例如,嚴格的 HTML 4 DTD 禁止任何深度的’a’元素對另一’a’元素的嵌套。在XML中無法寫出這樣的禁止。盡管這些禁止不能在DTD中定義,一些元素不應該被嵌套。在標準化的附錄B Appendix B中是這些元素的匯總。

              具有 'id' 和 'name' 屬性的元素

              HTML 4 定義了name屬性的元素有 a,applet,form,frame,iframe,img,and map. HTML 4還引入了 id 屬性. 這兩個屬性都是被設計作為片段標識符。

              在XML中,片段標識符是ID類型,每個元素只能有一個ID類型的屬性。因此,在XHTML1.0中,id屬性被定義為ID類型。為保證XHTML1.0文檔是結構良好的XML文檔,在定義一個片段標識符時,XHTML文檔必須使用id屬性,即使是對那些以前用name屬性的元素。請參看 HTML Compatibility Guidelines 的信息,確保XHTML文檔以text/html媒體類型使用時,這些”錨”能向后兼容。

              注意,在XHTML 1.0中,name 屬性不被正式支持,在以后的XHTML版本中將被刪除。
              回復  更多評論   

          • # Xhtml學習2  self Posted @ 2006-12-12 15:19
            Xhtml學習2
            1、選擇什么樣的DOCTYPE
            1)過渡的(transitional):要求非常寬松的DTD,它允許你繼續使用html4.01的標識(但是要符合xhtml的寫法)。完整代碼如下:
            <!DOCTYPE html PUBLIC "-//W3C//DTD xhtml 1.0 Transitional//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            (2)嚴格的(strict):要求嚴格的DTD,你不能使用任何表現層的標識和屬性,例如。完整代碼如下:<!DOCTYPE html PUBLIC "-//W3C//DTD xhtml 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
            (3)框架的(frameset):專門針對框架頁面設計使用的DTD,如果你的頁面中包含有框架,需要采用這種DTD。完整代碼如下:
            <!DOCTYPE html PUBLIC "-//W3C//DTD xhtml 1.0 Frameset//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

            2、什么是名字空間
            <html xmlns="http://www.w3.org/1999/xhtml" lang="gb2312">
            "xmlns"是xhtml namespace的縮寫,叫做"名字空間"聲明.

            3、定義語言編碼
            <meta http-equiv="content-type" content="text/html; charset=gb2312" /><meta http-equiv="content-language" content="gb2312" /> 這是針對老版本瀏覽器寫的,以保證各種瀏覽器都能正確解釋頁面,xhtml語法規則要求所有的標識都必須有開始和結束。例如<body>和</body>、<p>和</p>等,對于不成對的標識,要求在標識最后加一個空格,然后跟一個"/"。例如<br>寫成<br />、<img>寫成<img />,加空格的原因是避免代碼連在一起瀏覽器不識別。</p>
              回復  更多評論   

          • # js全屏  self Posted @ 2006-12-12 17:02
            <html>
            <head><meta http-equiv="content-type" content="text/html; charset=gb2312">
            <!-- 禁止頁面被緩存 -->
            <meta http-equiv="Pragma" CONTENT="no-cache">
            <meta http-equiv="Expires" CONTENT="0">
            <meta http-equiv="Cache-Control" CONTENT="no-cache">

            <!-- 網頁特效 -->
            <meta http-equiv="Page-Enter" content="revealTrans(duration=2, transition=12)">
            <meta http-equiv="Page-Exit" content="revealTrans(duration=2, transition=12)">
            <title>本頁面實現全屏方式跳出另一個頁面后關閉自己</title>
            <script>
            <!--
            function init() {
            cnrWin = window.open("test.htm", "cnr", "fullscreen=yes");
            }

            function closeSelf() {
            window.focus();
            document.all.WebBrowser.ExecWB(45,1);
            cnrWin.focus();
            }
            //-->
            </script>
            </head>

            <!-- 無提示對話框關閉窗口 -->
            <object id="WebBrowser" width=0 height=0
            classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
            </object>

            <body leftmargin="0" topmargin="0" onload="init()"
            onblur="closeSelf();">
            </body>

            </html>
              回復  更多評論   

          • # re: JS集錦  self Posted @ 2006-12-13 14:20
            在函數里加上這兩句會使網頁露出任務欄
            cnrWin .moveTo(0,0);
            cnrWin .resizeTo(screen.availWidth,screen.availHeight);  回復  更多評論   

          • # 可以使層的背景色變透明的兩個css樣式  self Posted @ 2007-01-09 15:21
            可以使層的背景色變透明的兩個css樣式
            background-color : transparent ;
            filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=100);  回復  更多評論   

          • # re: JS集錦  myself Posted @ 2007-07-23 14:09
            <script type="text/javascript">
            // --- 設置cookie
            function setCookie(sName,sValue,expireHours) {

            var cookieString = sName + "=" + escape(sValue);
            //;判斷是否設置過期時間
            if (expireHours>0) {
            var date = new Date();
            date.setTime(date.getTime + expireHours * 3600 * 1000);
            cookieString = cookieString + "; expire=" + date.toGMTString();
            }
            document.cookie = cookieString;
            }

            //--- 獲取cookie
            function getCookie(sName) {
            var aCookie = document.cookie.split("; ");
            for (var j=0; j < aCookie.length; j++){
            var aCrumb = aCookie[j].split("=");
            if (escape(sName) == aCrumb[0])
            return unescape(aCrumb[1]);
            }
            return null;
            }
            </script>
            <BODY onLoad="if(getCookie('1')!=null)document.getElementById('name').value=getCookie('1')">
            <form name="f1">
            <input name="name" id="name"type="text" value=""/><br/>
            <input type="text" name="password" ><br/>
            <input type="checkbox" name="remenberMe" onClick=";alert(已經設置)" />記住我

            <input type="submit" onClick="if(f1.remenberMe.checked==true)setCookie('1',f1.name.value,24) ;"/>
            </form>
              回復  更多評論   

          • # javascript setCookies  myself Posted @ 2007-07-23 14:10
            above is javascript setCookies   回復  更多評論   

           
          Copyright © 智者無疆 Powered by: 博客園 模板提供:滬江博客


             觀音菩薩贊

          主站蜘蛛池模板: 台北市| 九龙县| 比如县| 泸西县| 长海县| 弥渡县| 镇远县| 普格县| 拉萨市| 文山县| 巩义市| 隆安县| 鄂托克旗| 宁津县| 瓦房店市| 乌拉特后旗| 西乌珠穆沁旗| 望谟县| 开封县| 元朗区| 湖南省| 江西省| 南皮县| 庆云县| 琼结县| 杨浦区| 柳江县| 永登县| 柏乡县| 周口市| 武功县| 根河市| 丽水市| 汝南县| 贵定县| 平乐县| 宁国市| 根河市| 赞皇县| 崇文区| 玛纳斯县|