posts - 27,comments - 2,trackbacks - 0
          <!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" xml:lang="en">
          <head>
          <meta http-equiv="Content-Type" content="text/html;charset=GBK" />
          <title></title>
          </head>
          <body>
          <h1>提示離開(kāi)當(dāng)前頁(yè)面的js代碼</h1>
          <a >百度鏈接</a>
          <script type="text/javascript">
          if (window != top) {
          top.location.href = "login.action";
          } else {
          if (window.Event) {
          window.onbeforeunload = function(event) {
          return "你是否要離開(kāi)此頁(yè)面,離開(kāi)此頁(yè)面信息將不被保存!";
          };
          } else {
          window.onbeforeunload = function() {
          return "你是否要離開(kāi)此頁(yè)面,離開(kāi)此頁(yè)面信息將不被保存!";
          };
          }
          }
          </script>
          </body>
          </html>
          posted @ 2013-07-18 15:04 魏文甫 閱讀(247) | 評(píng)論 (0)編輯 收藏
          Ajax同步加載數(shù)據(jù)。發(fā)送請(qǐng)求時(shí)鎖住瀏覽器。需要鎖定用戶交互操作時(shí)使用同步方式。 
          $.ajax({
            url: "some.php",
            async: false
           })
          posted @ 2013-07-11 15:48 魏文甫 閱讀(454) | 評(píng)論 (0)編輯 收藏
          String data_ = "2013-07-01 15:47:34";
          SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
          Date date = simpleDateFormat.parse(data_);
          格式y(tǒng)yyy-MM-dd HH:mm:ss是24小時(shí)制,yyyy-MM-dd hh:mm:ss是12小時(shí)制。
          posted @ 2013-07-01 15:48 魏文甫 閱讀(195) | 評(píng)論 (0)編輯 收藏
           
                
                /**
          * 得到幾天前的時(shí)間
          * @param d
          * @param day
          * @return
          */
          public static Date getDateOfBefore(Date d, int day) {
          Calendar now = Calendar.getInstance();
          now.setTime(d);
          now.set(Calendar.DATE, now.get(Calendar.DATE) - day);
          return now.getTime();
          }
                /**
          * 得到幾天后的時(shí)間
          * @param d
          * @param day
          * @return
          */
          public static Date getDateOfAfter(Date d, int day) {
          Calendar now = Calendar.getInstance();
          now.setTime(d);
          now.set(Calendar.DATE, now.get(Calendar.DATE) + day);
          return now.getTime();
          }
          posted @ 2013-06-28 17:55 魏文甫 閱讀(287) | 評(píng)論 (0)編輯 收藏
          在struts2中配置:<constant name="struts.multipart.saveDir" value="D:\\uploadFiles\\temp\\temp"></constant>

          類似的其他的配置有:
          <constant name="struts.convention.default.parent.package"
          value="crud-default" />
          <package name="crud-default" extends="convention-default">
          <interceptors>
          <interceptor name="checklogin"
          class="com.xiaowei.interceptor.CheckLoginInterceptor"></interceptor>
          <interceptor-stack name="crudStack">
          <interceptor-ref name="store">
          <param name="operationMode">AUTOMATIC</param>
          </interceptor-ref>
          <interceptor-ref name="paramsPrepareParamsStack" />
          <interceptor-ref name="checklogin">
          <param name="user">user</param>
          <param name="exclude">
          login,verifyAccount,login.jsp,image
          <!--有待添加 -->
          </param>
          </interceptor-ref>
          </interceptor-stack>
          </interceptors>
          <default-interceptor-ref name="crudStack" />
          <global-results>
          <result name="loginFail" type="dispatcher">/index.jsp
          </result>
          </global-results>
          <!-- <interceptor-stack name="fileUploadMaxSize" class="com.xiaowei.interceptor.CheckFileLengthMax"> 
          <interceptor-ref name="fileUpload"/> <interceptor-ref name="basicStack"/> 
          </interceptor-stack> -->
          </package>
          <constant name="struts.multipart.maxSize" value="20480000000"></constant>
          <constant name="struts.multipart.saveDir" value="D:\\uploadFiles\\temp\\temp"></constant>

          posted @ 2013-06-27 13:13 魏文甫 閱讀(409) | 評(píng)論 (0)編輯 收藏
          在簡(jiǎn)單地main函數(shù)中輸出的結(jié)果:0.8999999999999999;而非0.9;因?yàn)槭且远M(jìn)制存儲(chǔ)的,所以不能除盡1/10。
          解決方法有:1,System.out.printf("%.1f",2.0-1.1);   
          還有一個(gè)網(wǎng)上看到的:在double變量存入堆時(shí)確保精度的方法: System.out.println(new BigDecimal(1.1)); 輸出的值為一大長(zhǎng)串為:1.100000000000000088817841970012523233890533447265625
          posted @ 2012-02-28 19:17 魏文甫 閱讀(836) | 評(píng)論 (0)編輯 收藏
          好些天沒(méi)更新了,有些牽絆耽擱了很久,要慢慢拾起來(lái)......我要培養(yǎng)自己做一個(gè)有始有終的人。
          posted @ 2012-02-22 20:46 魏文甫 閱讀(152) | 評(píng)論 (0)編輯 收藏
          HTML中的一些對(duì)象()
          使用DOM-Document Object Model操作對(duì)象getElementById();getElementsByName();等
          而改變標(biāo)簽里的內(nèi)容要用.innerHTML,改變鏈接用.href例如:
          <!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>
          <title></title>
          <script type="text/javascript">
          function changerButton(){
          var link = document.getElementById("links");
          link.innerHTML = "NetEasy";//改變a標(biāo)簽里的內(nèi)容即改變了Sina
          link.;//鏈接改變了
          }
          </script>
          </head>
          <body>
          <a >Sina</a>
          <input type="button" value="Change" id="myButton" onclick="changerButton()"/>
          </body>
          </html>
          javascript里的一些應(yīng)用:例如<!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>
              <title></title>
              <script type="text/javascript">
                  var count = 0;
                  var st;
                  function showDiv() {        
                      count++;
                      if(count >=10) {
                          clearTimeout(st);        
                      } else {
                          var div = document.getElementById("myDiv");
                          div.innerHTML = div.innerHTML + "I love you!";
                          st = setTimeout("showDiv()",200);
                      }
                  }
              </script>
          </head>
          <body>
              <div id="myDiv"></div>
              <input type="button" value="I love you!" onclick="showDiv()" />
          </body>
          </html>
          script里可以嵌套if語(yǔ)句等
          一些網(wǎng)頁(yè)里的時(shí)間顯示也可以用javascript來(lái)寫例如顯示時(shí)間的走動(dòng)的簡(jiǎn)單的頁(yè)面:
          <!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>
              <title></title>
          </head>
          <body>
              <div id="timer"></div>
              <input type="button" value="showTime" onclick="showTimer()"  />
              <script type="text/javascript">        
                  function showTimer() {
                      var mydate = new Date();
                      var text = mydate.toLocaleString();
                      var div = document.getElementById("timer");
                      div.innerHTML = text;
                      setTimeout("showTimer()",1000);
                  }
                  window.onload = showTimer();
              </script>
          </body>
          </html>


          圖中時(shí)間顯示為走動(dòng)的狀態(tài)(時(shí)間在變)。
          posted @ 2011-12-05 21:05 魏文甫 閱讀(217) | 評(píng)論 (0)編輯 收藏
          JavaScript是編程語(yǔ)言,它跟html,css不同,簡(jiǎn)單的理解為:html的作用是你所寫的網(wǎng)頁(yè)的內(nèi)容,css是你對(duì)所寫網(wǎng)頁(yè)內(nèi)容的布局(內(nèi)容所在的位置,顏色,圖片等的美化),JavaScript是對(duì)網(wǎng)頁(yè)等得一些驗(yàn)證,切換的效果等等。JavaScript一般寫在最后面(因?yàn)榫W(wǎng)頁(yè)顯示時(shí)按順序顯示,一個(gè)網(wǎng)頁(yè)最重要的內(nèi)容要先顯示,再出現(xiàn)效果,而效果要比內(nèi)容長(zhǎng)得多)。
          JavaScript可以在里面寫if...else語(yǔ)句,for語(yǔ)句,while語(yǔ)句等,但和java的語(yǔ)法不同;例如一個(gè)不太規(guī)范簡(jiǎn)單的例子: 
           1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
           2 <html xmlns="http://www.w3.org/1999/xhtml">
           3 <head>
           4     <title></title>
           5     <script type="text/javascript">        
           6         var a=prompt("請(qǐng)輸入a的值:");
           7         var b=prompt("請(qǐng)輸入b的值:");
           8         alert("a+b的和為:"+(parseInt(a)+parseInt(b)));    
           9     </script>
          10 </head>
          11 <body>    
          12 </body>
          13 </html>
          輸入兩個(gè)值后結(jié)果為一個(gè)兩數(shù)和的窗口。

          JavaScript寫在function中,函數(shù)是由事件觸發(fā)的,例:
           1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
           2 <html xmlns="http://www.w3.org/1999/xhtml">
           3 <head>
           4     <title></title>
           5     <script type="text/javascript">        
           6         function sayHello(){
           7             var name=document.myform.mytext.value;
           8             alert("提交:"+name);
           9         }
          10         function clearMe(){
          11             document.myform.mytext.value="";
          12         }
          13     </script>    
          14 </head>
          15 <body>
          16     <form action="" name="myform">
          17         <input type="text" name="mytext" id="" value="" onclick="clearMe()"/>
          18         <input type="button" name="click me" value="提交" onclick="sayHello()"/>        
          19     </form>
          20 </body>
          21 </html>
          輸入一個(gè)值后彈出一個(gè)窗口:例
          posted @ 2011-12-03 23:17 魏文甫 閱讀(330) | 評(píng)論 (0)編輯 收藏
          HTML的定位
          HTML中要顯示有層次時(shí)用定位;定位有絕對(duì)定位,相對(duì)定位和固定定位。
          1.絕對(duì)定位:在選擇器中用position:absolute;此時(shí)它有類似與浮動(dòng)的效果,相當(dāng)于脫離了文檔流,如:
           1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
           2 <html xmlns="http://www.w3.org/1999/xhtml" 
           3 <head>
           4     <title></title>
           5     <style type="text/css">
           6         body{
           7             margin:0px;;
           8         }
           9         .div1{
          10             width:100px;
          11             height:100px;
          12             background-color:#669900;
          13             position:absolute;
          14         }
          15         .div2{
          16             width:200px;
          17             height:50px;
          18             background-color:#aa00ff;
          19         }
          20     </style>    
          21 </head>
          22 <body>
          23     <div class="div1">div1</div>
          24     <div class="div2">div2</div>
          25 </body>
          26 </html>

          此時(shí)div1像浮動(dòng)了,div2補(bǔ)上div1的位置(即有浮動(dòng)的效果,div2被div1遮住了)
          此時(shí)如果定義它的高和距離左右,定義的是該塊距離它的上一級(jí)(即它的父)的距離
           1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
           2 <html xmlns="http://www.w3.org/1999/xhtml" 
           3 <head>
           4     <title></title>
           5     <style type="text/css">
           6         body{
           7             margin:0px;;
           8         }
           9         .div1{
          10             width:100px;
          11             height:100px;
          12             background-color:#669900;
          13             position:absolute;
          14             top:10px;
          15             right:10px;
          16         }
          17         .div2{
          18             width:200px;
          19             height:50px;
          20             background-color:#aa00ff;
          21         }
          22     </style>    
          23 </head>
          24 <body>
          25     <div class="div1">div1</div>
          26     <div class="div2">div2</div>
          27 </body>
          28 </html>

          2.相對(duì)定位:position:relative;相對(duì)定位也有浮動(dòng)的效果,只是它相對(duì)于原來(lái)的位置發(fā)生了偏移。例如: 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
           2 <html xmlns="http://www.w3.org/1999/xhtml" 
           3 <head>
           4     <title></title>
           5     <style type="text/css">
           6         body{
           7             margin:0px;;
           8         }
           9         .div1{
          10             width:100px;
          11             height:100px;
          12             background-color:#669900;
          13             position:relative;
          14             top:10px;
          15             left:10px;
          16         }
          17         .div2{
          18             width:200px;
          19             height:50px;
          20             background-color:#aa00ff;
          21         }
          22     </style>    
          23 </head>
          24 <body>
          25     <div class="div1">div1</div>
          26     <div class="div2">div2</div>
          27 </body>
          28 </html>

          當(dāng)在body中為絕對(duì)定位時(shí),其父為相對(duì)定位如: 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
           2 <html xmlns="http://www.w3.org/1999/xhtml">
           3 <head>
           4     <title></title>
           5     <style type="text/css">
           6         body{
           7             margin:0px;
           8         }
           9         div{
          10             width:200px;
          11             height:200px;
          12         }
          13         .div1 {
          14             background-color:#ccc;
          15             position:absolute;
          16             bottom:0px;
          17             right:0px;
          18             z-index:999;
          19         }
          20         .div2 {
          21             margin-left:60px;
          22             width:500px;
          23             height:300px;
          24             background-color:#ff6600;
          25             position:relative;
          26         }
          27         
          28     </style>
          29 </head>
          30 <body>    
          31     <div class="div2">DIV2
          32         <div class="div1">DIV1</div>
          33     </div>
          34 </body>
          35 </html>

          此時(shí)div1的位置是相對(duì)于div2的位置來(lái)說(shuō)的。
          3.固定定位:固定定位個(gè)人認(rèn)為可以理解為固定于瀏覽器邊框,不隨滾動(dòng)條的滾動(dòng)而滾動(dòng):如:
           1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
           2 <html xmlns="http://www.w3.org/1999/xhtml" 
           3 <head>
           4     <title></title>
           5     <style type="text/css">
           6         body{
           7             margin:0px;;
           8         }
           9         .toolbar{
          10             height:30px;
          11             width:100%;
          12             background-color:green;
          13             position:fixed;
          14             top:0px;
          15             left:0px;
          16         }
          17         .div{
          18             width:150px;
          19             height:150px;
          20             background-color:#ff0000;
          21         }
          22     </style>    
          23 </head>
          24 <body>
          25     <div class="toolbar"></div><br/>
          26     <div class="div">div1</div><br/>
          27     <div class="div">div2</div><br/>
          28     <div class="div">div3</div><br/>
          29     <div class="div">div4</div><br/>
          30     <div class="div">div5</div><br/>
          31     <div class="div">div6</div><br/>
          32     <div class="div">div7</div><br/>
          33     <div class="div">div8</div>    <br/>
          34     <div class="div">div9</div><br/>
          35     <div class="div">div0</div><br/>
          36 </body>
          37 </html>
          posted @ 2011-12-01 18:57 魏文甫 閱讀(5301) | 評(píng)論 (1)編輯 收藏
          僅列出標(biāo)題
          共3頁(yè): 上一頁(yè) 1 2 3 下一頁(yè) 
          主站蜘蛛池模板: 黄骅市| 灵璧县| 宣恩县| 炉霍县| 临朐县| 湖南省| 怀安县| 清远市| 永吉县| 仪征市| 息烽县| 务川| 扎兰屯市| 思南县| 勐海县| 阳春市| 丁青县| 什邡市| 灵山县| 保靖县| 防城港市| 蒙山县| 扎鲁特旗| 安新县| 广元市| 西乌珠穆沁旗| 德江县| 东阳市| 安康市| 渑池县| 定州市| 韶关市| 黄大仙区| 滨州市| 临西县| 哈尔滨市| 团风县| 会泽县| 北京市| 宁波市| 闽侯县|