以前调试脚本的时候一般都使用debugger;语法。但系统重装后不知道为什么没有作用了。后来网上查了原来是cookie里少一个名为ASPCLIENTDEBUG键值。以下是MSDN上如何启动客户端调试的方法。引用如下:
1.创建如下代码的html文件
<html>
<head>

<script language="JavaScript">

function set ()
{
 
var expdate = new Date(); 
 expdate.setMonth(expdate.getMonth()
+6);
 alert(
"setting cookie \""+form1.txtName.value+"\" to \""+form1.txtValue.value+"\"");
 setCookie(form1.txtName.value, form1.txtValue.value, expdate); 
}


function get ()
{
 alert(
"getting cookie \""+form1.txtName.value+"\"");
 
var c = getCookie(form1.txtName.value);
 alert( 
"cookie = "+c );

 form1.txtValue.value 
= c;
}


function getCookie (sCookieName)
{
 
var sName=sCookieName+"=", ichSt, ichEnd;
 
var sCookie=document.cookie;

 
if ( sCookie.length && ( -1 != (ichSt = sCookie.indexOf(sName)) ) )
 
{
    
if (-1 == ( ichEnd = sCookie.indexOf(";",ichSt+sName.length) ) )
    ichEnd 
= sCookie.length;
    
return unescape(sCookie.substring(ichSt+sName.length,ichEnd));
 }


 
return null;
}

   
function setCookie (sName, vValue)
{
 
var argv = setCookie.arguments, argc = setCookie.arguments.length;
 
var sExpDate = (argc > 2? "; expires="+argv[2].toGMTString() : "";
 
var sPath = (argc > 3? "; path="+argv[3] : "";
 
var sDomain = (argc > 4? "; domain="+argv[4] : "";
 
var sSecure = (argc > 5&& argv[5? "; secure" : "";
 document.cookie 
= sName + "=" + escape(vValue,0+ sExpDate + sPath + sDomain + sSecure + ";";
}

    
function deleteCookie (sName)
{
 document.cookie 
= sName + "=" + getCookie(sName) + "; expires=" + (new Date()).toGMTString() + ";";
}


</script>

</head>

<body>

<form name=form1>
   cookie name:
<input type="text" name="txtName" value="ASPCLIENTDEBUG"><p>
   cookie value:
<input type="text" name="txtValue" value="doesn't matter"><p>
   
<input type="button" value="Set Cookie" onClick="set()">
   
<input type="button" value="Get Cookie" onClick="get()">
</form>
</body>
</html>
2.把次文件命名为cookie.html
3.保存至c:\inetput\wwwroot\文件夹下
4.打开IE,输入http://localhost/cookie.html,点击设置cookie按钮即可。
posted on 2007-08-30 09:47    阅读(498)  评论(0)    收藏  举报