來CSDN的WEB區有兩年了(大部分都在Javascript區),一直沒時間整理自已在CSDN回答的比較好的問題,大部分討論主題頁面都已經不存在了,今天有時間,現收集整理了一些認為比較好的常見問題。
ASP問題、Javascript問題:
Q: javascript數組的長度不能超過多大?
see MSDN:
---------------
If only one argument is passed to the Array constructor, and the argument is a number, it must be an unsigned 32-bit integer (< approximately four billion). That value then becomes the size of the array
---------------
如果僅用一個參數構造這個數組,且這個參數是一個數字,它必須是一個無符號32位整型(小于大約40億),因而這個數字成為這數組的大小。
Q: 有沒有測試客戶端系統的函數,比如用戶所使用的系統 是繁體 系統 還是簡體 系統,或者測試客戶端的區域設置的函數!!
我只知道除了在Asp中用Request.ServerVariables得到客戶端瀏覽器信息,還可以用JScript的navigator對象得到系統/版本等
詳見MSDN
Q:
<table id="test">
<tr><td><input></td><td><input></td></tr>
</table>
我現在想在test中在增加一個tr串該怎么弄?
我用了createElement 怎么不行?
<table id="test">
<tr><td><input></td><td><input></td></tr>
</table>
<input type=button value="insert" onclick="fnAddTr()">
<script>
function fnAddTr()
{
var oRow = test.insertRow();
var oCell = oRow.insertCell();
oCell.innerText = "insert row";
}
</script>
Q:在javascript中命名分組的正則表達式是怎樣寫的,然后怎樣利用命名替換或取出該命名級匹配的值?
str = "123456789324";
alert(str.replace(/(\d{4})(\d{3})(\d{5})/g, "$1-$2-$3"));
Q:我怎么顯示不出圖象?大俠幫我看看我的代碼:
<!--#include file="../sql.asp"-->
<%
id=request("id")
server.CreateObject("ADODB.Recordset")
ssql="select img from mynews where id='" & id &"'"
rsPic.open ssql,conn,3,3
Response.ContentType = "image/*"
Response.BinaryWrite rsPic("img").getChunk(7500000)
'response.BinaryWrite rs.fields("LOGO_IMG")
response.write("end of the file")
rsPic.close
set rsPic=nothing
%>
看看你的asp文件中是否含有html代碼,如果有,那就刪掉,否則是不出現圖像的
另外,sql server存儲圖像數據會將最后一個\0結束符過濾掉,取出來后,請加上\0結束符
response.BinaryWrite rs.fields("LOGO_IMG") & chrb(0)
Q: 作參數的數據類型問題
function editit(id)
{
page="adminuseredit.asp?userid="+id
window.open (page,'編輯用戶','width=500,height=350')
}
<a href="javascript:editit(<%=rs("userid")%>)">
<img border="0" src="image/EDIT.GIF" alt="查看/編輯"></a>
rs("userid")是varchar類型,當它的值是數字時,如"0001",以上程序正常,但若它的值是字符串的話,如"student",程序會報錯:'student'未定義.
請教高手這如何解決????
傳值的參數變量類型未定義,你是作為一個變量傳進去的,而這個變量未定義,運行時將捕獲這個錯誤,加上引號后是作為常量傳進去,不會報錯
Q:求簡潔高效的判斷IE版本的JS
with(navigator)
{
alert(appName == "Microsoft Internet Explorer" && parseInt(appVersion) == 4);
}
Q:如何判斷XMLHTTP是否成功讀取網頁的內容?
var obj = new ActiveXObject("Microsoft.XMLHTTP");
obj.open("POST","Server.asp?sel="+str,false);
obj.send();
------------
執行obj.send(); 后如何判斷XMLHTTP是否成功讀取網頁的內容?
try:
If (obj.Status == 200)
GetHTML = obj.ResponseText;
note:
obj.open("POST","Server.asp?sel="+str,true); // last a parameter must be ture
異步傳輸
Q:window.showModelessDialog已經產生了這個窗口,怎么才能再改變這個窗口的大???
<script language="Javascript">
function showModel(){
var wnd = window.showModelessDialog('test.htm',null,'dialogWidth=0px;dialogHeight=0px;status:0;help:0;resizable:1;unadorned:1');
wnd.dialogHeight = "600px";
wnd.dialogWidth = "800px";
wnd.dialogLeft = "0px";
wnd.dialogTop = "0px";
}
</script>
<input type="button" value="ShowModel" onclick="showModel()">