2013年4月30日 星期二

針對IE 改寫 table

使用時機:table 沒有特定下使用

//針對div .mintabletwo底下數個table 且沒有class。
$(function(){
 var version = $.browser.msie;
  
 if(version){ //因為ie會把表格線弄的很淡,所以在這邊動點手腳。如果會影響到表格的影響,請更改之。
  $('.mintabletwo table').each(function(index){
   var wid_var=$(this).attr('border');
   if (typeof wid_var === "undefined"|| wid_var=='0'){
    $('.mintabletwo table:eq('+index+')').addClass('noLine');
   }else{
    $('.mintabletwo table:eq('+index+')').addClass('haveLine');
   }
  })
  $('.haveLine').css('border', '1px solid black');
 }
})


補充說明:
.eq() 教學連結
.find() 教學連結
.addClass() 教學連結

2013年4月29日 星期一

水平menu

網址:http://css.maxdesign.com.au/listutorial/horizontal_master.htm

CSS CODE
#navcontainer ul
{
margin: 0;
padding: 0;
list-style-type: none;
text-align: center;
}

#navcontainer ul li { display: inline; }

#navcontainer ul li a
{
text-decoration: none;
padding: .2em 1em;
color: #fff;
background-color: #036;
}

#navcontainer ul li a:hover
{
color: #fff;
background-color: #369;
}


HTML CODE
<div id="navcontainer">
<ul>
<li><a href="#">Milk</a></li>
<li><a href="#">Eggs</a></li>
<li><a href="#">Cheese</a></li>
<li><a href="#">Vegetables</a></li>
<li><a href="#">Fruit</a></li>
</ul>
</div>


微軟作業系統 關機指令 shutdown

一直忘記,所以寫這篇,方便自己檢索。

方法1:


  • 立即關機:shutdown -s -t 0
  • 登出:shutdown -l
  • 立即重新啟動:shutdown -r -t 0
  • 30秒後關機:shutdown -s -t 30
  • 1小時後關機:shutdown -s -t 3600
  • 3小時後關機:shutdown -s -t 10800
  • 取消關機 SHUTDOWN -a


方法2:

開始→執行→輸入『taskmgr』→WINDOWS工作管理員→工具列有一個選項『關機』

2013年4月23日 星期二

排序更改

示意片:

$sort =$_POST['sort'];
$sortBL =$_POST['sortBL'];
$year =$_POST['year'];
$cat =$_POST['cat'];
$id =$_POST['sn'];
//B 代表 前面
//L 代表 後面
 if($sort=='abcd')
  echo_script_alert_ref("無效選擇,請勿選擇自己","XXXXX");
      
 if($sortBL=='B'){//改到xxx之前
  $sql="UPDATE col_doc_xxx SET sort=sort+1 WHERE sort >= '$sort' AND year_sn='$year' AND cat_sn='$cat'";      
  mysql_query($sql);
  //塞此id 的sort 為$sort
  $sql="UPDATE col_doc_xxx SET sort=$sort WHERE file_sn='$id'";
  mysql_query($sql);
 }
 if($sortBL=='L'){// 改到XXX之後
  $sql="UPDATE col_doc_xxx SET sort=sort-1 WHERE sort <= '$sort' AND year_sn='$year' AND cat_sn='$cat'";      
  mysql_query($sql);
  //塞此id 的sort 為$sort
  $sql="UPDATE col_doc_xxx SET sort=$sort WHERE file_sn='$id'";
  mysql_query($sql);
 }
 echo_script_alert_ref("更新完成","xxx");

過濾$_GET和$_POST

Q:從使用者輸入篩除危險的字元
<?php
/*
判斷傳遞的變量中是否含有非法字符 
//要過濾的非法字符 如post get
*/

$ArrFiltrate=array("’",";","union","true","../"); 
//出錯後要跳轉的url,不填則默認前一頁 
$StrGoUrl="http://XXX.tw"; 
 //是否存在數組中的值 
function FunStringExist($StrFiltrate,$ArrFiltrate){
 foreach ($ArrFiltrate as $key=>$value){
  if(eregi($value,$StrFiltrate)){
   return true;
  }
 }
 return false;
}
foreach($_POST as $key=>$value){
 $ArrayPostAndGet[]=$value;
}
foreach($_GET  as $key=>$value){
 $ArrPostAndGet[]=$value;
}
//驗證開始
foreach($ArrPostAndGet as $key=>$value){

 if(FunStringExist($value,$ArrFiltrate)){
  
  if(empty($StrGoUrl)){
   echo "<script>history.go(-1);</script>";
  }else{   
   echo_script_alert_ref("非法字符",'');
  }
 }
}
?>



範例:以下連結會被過濾 將不能執行

正確網址加 /index.php?module=Opportunities&action=/../../../../../../../../boot.ini%
00&advanced=true HTTP/1.0

2013年4月12日 星期五

Twitter Bootstrap 網頁美化工具


Sleek, intuitive, and powerful front-end framework for faster and easier web development.


     

Q:怎麼對select 或input 標籤做寬度(width)設定?

.input-small-mini 30px,
.input-mini .... 60px, 
.input-small  .... 90px,
.input-besmall.....110px(個人新增)
.input-medium  .... 150px,
.input-large  ....210px,
.input-xlarge  .... 270px,
.input-xxlarge  .... 530px,


Q:怎麼對button或input 加入顏色?


class加入btn ,這是基本的
加入顏色可以指定"btn btn-primary" 可以有藍色且立體的視覺感。

如果要加入其他顏色的,必需在bootstrap.css加入客製的CSS,可以利用下面網頁方便完成。
http://charliepark.org/bootstrap_buttons/

Q:BUTTON怎麼加入小圖案icon

參考:http://www.plugolabs.com/twitter-bootstrap-button-generator/
http://twitter.github.io/bootstrap/base-css.html#icons
語法: class="icon-white icon-heart"


Q:在瀏覽器IE 可以使用嗎?

  無法在 IE 7 8 9 (俗稱的舊版 IE)完整顯示。因為舊版IE末完整支援HTML5

2013年4月11日 星期四

input加入灰色提示文字

<input type='text' name='e_title' size='40' style="color:#999999" value='請填入含年度的考古題標題' onfocus="if (this.value=='請填入含年度的考古題標題') this.value='';this.style.color='#000';" onblur="if (this.value==''){this.value='請填入含年度的考古題標題';this.style.color='#999';}">(範例:<b>一零一學年度碩士班招生考試試題 </b>)<br>

pci簡單通訊控制器 是什麼?

在灌筆電時,這個東西一直找不到適當的驅動來使用。

只好有請狗歌大大了。

這篇有提到:
http://www.mobile01.com/topicdetail.php?f=514&t=1865568

原來是要灌intel的東西
https://downloadcenter.intel.com/Detail_Desc.aspx?agr=Y&DwnldID=18532&ProdId=3150&lang=eng

2013年4月9日 星期二

ini_set error 、DIRECTORY_SEPARATOR

設定php發生錯誤的等級
ini_set('error_reporting', E_ALL);

ConstantDescriptionNote
E_NOTICERun-time notices. Indicate that the script encountered something that could indicate an error, but could also happen in the normal course of running a script.
E_STRICTEnable to have PHP suggest changes to your code which will ensure the best interoperability and forward compatibility of your code.Since PHP 5 but not included in E_ALL until PHP 5.4.0
E_ALLAll errors and warnings, as supported, except of level E_STRICT prior to PHP 5.4.0.


ini_set('error_reporting', E_ALL);
ini_set('track_errors', '1');
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');

DIRECTORY_SEPARATOR

DIRECTORY_SEPARATOR是php的內部常量,用於顯示系統分隔符的命令,不需要任何定義與包含即可直接使用。在windows下路徑分隔符是\(當然/在部分系統上也是可以正常運行的),在linux上路徑的分隔符是/,這就導致了一個問題,比如伺服器是windows,有一個圖片上傳程序,伺服器上指定的上傳文件保存目錄是define('ROOT', dirname(__FILE__)."/upload");

於是php引入了DIRECTORY_SEPARATOR變量,可以將上面的寫法改寫为:
define('ROOT', dirname(__FILE__).DIRECTORY_SEPARATOR."upload");

引申閱讀:


  1.     上傳圖片
  2.    上傳檔案簡易版

2013年4月2日 星期二

HTML5 取代部份javascript

javascript 一載入就停駐在頁數(focus)

Javascript+HTML:
書名:<input type="text" name="a" id="a"/><br/>
頁數:<input type="text" name="b" id="b"/>
<script type="text/javascript">
 document.getElementById("b").focus();
</script>
HTML5:(並非所有的瀏覽器都支援)可支援:IE9、chrome
在頁數的input加入autofocus
書名:<input type=text name=a /><br/>
頁數:<input type=text autofocus name=b />

sort 數字和非數字

資料需要鍵入一個值當成資料的排序,使用非數字依然是沒什麼問題。
可是當要用來更改排序時,比大小就會出現狀況,可能會有多個值是會被符合的。

比如說,我要把比5大的sort都加1,那比5大的會有哪些呢? 這就是一個問題。