我在CSDN回答的ASP和Javascript问题集锦

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 yjgx007 的 blog

来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()">

本文关键:我在CSDN回答的ASP和Javascript问题集锦
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top