| 
 | 
 
 
在網站建設過程中,不管您是用PHP還是其它jsp、asp、.net等,都或多或少地要用到javascript、div+CSS等。在使用的過程中您也可以會遇到以下幾個問題,如果早些知道,可以少些鬱悶。 
 
1.要使li沒有符號,用list-style:none;還要li外面有lu,而且是緊跟著。這在網站建設的做DIV+CSS裡會遇到。 
如 
  
<ul> 
   <li></li> 
  <li></li> 
</ul> 
如下可能無效: 
<ul> 
.....這是一串代碼..... 
  <li></li> 
  <li></li> 
</ul>  
 
2.IE不支持getElementsByName() ,使用JAVASCRIPT時注意。 
 
3.用type=file控件上傳圖片,基於PHP語言的。 
 
  
<input name="pic" id="pic" type="file" enctype="multipart/form-data"/> 
上傳文件是先把文件讀到臨時目錄裡,然後用copy()  
---------------------------------------------------------------  
改用新方法吧:  
$_FILES['userfile']['name']  
客戶端機器文件的原名稱。  
$_FILES['userfile']['type']  
文件的 MIME 類型,需要瀏覽器提供該信息的支持,例如「image/gif」。  
$_FILES['userfile']['size']  
已上傳文件的大小,單位為字節。  
$_FILES['userfile']['tmp_name']  
文件被上傳後在服務端儲存的臨時文件名。  
$_FILES['userfile']['error']  
和該文件上傳相關的錯誤代碼。['error'] 是在 PHP 4.2.0 版本中增加的。  
上傳文件: 
copy($_FILES["pic"]["tmp_name"], "upload/s.gif");  
4.文本框中設置為 disabled 時,文本框裡的內容裝不能讀出.. 
 
5.javascript 取得 iFrame內容  
  
<script language="javascript"> 
function setPath(){ 
if (document.all){//IE  
doc = document.frames[ "piciFrame"].document; 
}else{//Firefox  
doc = document.getElementById( "piciFrame").contentDocument; 
}  
doc.getElementById( "filepath").value="sds"; 
}  
</script>  6.utf-8編碼下包含文件時中文字亂碼的解決方法,如果不注意編碼問題,可能使得您在網站建設中遇到一些你覺得 
明明沒有什麼錯,但卻得不到預期的結果。 
 
方法:把被包含的(出現亂碼的)文件用EditPlus等工具打開,然後另存為,在「編碼」選項裡選擇「utf-u"就OK了 
 
7.htc 文字移動 取消點擊虛線  
 
  
<---------------Html 文件 -----------> 
<html>  
<head>  
<title> htc 文字移動 取消虛線</title >  
<style>  
.myfilter,a{behavior:url(htc2.htc);position:relative;} <!--設置position:relative才能移動--> 
a{behavior:url(htc2.htc)} 
</style>  
</head>  
<body>  
<span id="myspan" class="myfilter">行為產生的文字效果</span><br>  
<button>向右移動第一行文字</button><br>  
<button>向下移動第一行文字</button> 
<br><br> 
<a href="#">點擊後不再有虛線</a> 
</body>  
</html>  
<---------------------htc文件 命名為htc2.htc --------------> 
//添加「行為」當得到焦點時 
<public:attach event="onfocus" /> 
//添加方法  
//<public:method name="move_down" />  
//<public:method name="move_right" /> 
 
<script language="javascript">  
//定義向下移動文字的方法  
 
function move_down() {  
element.style.posTop+=2;  
} 
 
//定義向右移動文字的方法  
function move_right() {  
element.style.posLeft +=6;  
} 
//讓其失去焦點 
function example(){ 
element.blur();  
} 
 
</script>   
 
8.對於radio只能用getElementByName ,使用JAVASCRIPT時注意。 
 
 
  
// windon.opener 取得進入此頁面的上個頁面的對象  
function ha_select(){ 
var all_radio = document.getElementsByName("city"); //注意: 對於radio只能用getElementByName不能用 
getElementById - 取得所有單選元素 
for(var i=0; i<all_radio.length; i++){ //遍歷所有元素 
if(all_radio.checked){ // 如果該按鈕為選中狀態,剛取它的值  
window.opener.document.getElementById( "citydata").value=all_radio.value; //把該值附值給上個頁面 
中id為citydata的元素 
window.close(); //關閉此頁面 
break;  
}  
}  
}   
 
以上是在網站建設中前面設計和後台程序都可能會遇到的一些問題,如果不注意不瞭解,可能會讓你莫名其妙的困惑。 |   
 
 
 
 |