當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
net中的调试javascript脚本
生活随笔
收集整理的這篇文章主要介紹了
net中的调试javascript脚本
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
怎樣對.net中的javascript腳本進行調(diào)試?第一步:在IE的“Internet設(shè)置”中選擇“高級”——“安全”——“啟用集成windows身份驗證”(這一步很重要!!!)
第二步:同樣在“Internet設(shè)置”中把“禁止腳本調(diào)試”的勾去掉
第三步:用調(diào)試模式啟動程序
第四步:在vs.net的菜單選擇“調(diào)試”——“窗口”——“運行文檔”
第五步:在“運行文檔”窗口中雙擊要調(diào)試的文檔
第六步:在該文檔中需要的腳本開始調(diào)試的位置設(shè)置斷點
第七步:自己操作,令程序運行到斷點處,余下的就是調(diào)試程序了,我也不多說了。
注意,如果還是不行,那可能是缺少了一個名為“ASPCLIENTDEBUG”的cookie。設(shè)置這個cookie的方法:
1.創(chuàng)建包含以下代碼的 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.將此文件復(fù)制到
c:\inetput\wwwroot
4.在 Internet Explorer 的“地址”框中,鍵入:
http://localhost/cookie.html
5.在 http://localhost/cookie.html 窗口中,單擊“設(shè)置 Cookie”按鈕。
第二步:同樣在“Internet設(shè)置”中把“禁止腳本調(diào)試”的勾去掉
第三步:用調(diào)試模式啟動程序
第四步:在vs.net的菜單選擇“調(diào)試”——“窗口”——“運行文檔”
第五步:在“運行文檔”窗口中雙擊要調(diào)試的文檔
第六步:在該文檔中需要的腳本開始調(diào)試的位置設(shè)置斷點
第七步:自己操作,令程序運行到斷點處,余下的就是調(diào)試程序了,我也不多說了。
注意,如果還是不行,那可能是缺少了一個名為“ASPCLIENTDEBUG”的cookie。設(shè)置這個cookie的方法:
1.創(chuàng)建包含以下代碼的 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.將此文件復(fù)制到
c:\inetput\wwwroot
4.在 Internet Explorer 的“地址”框中,鍵入:
http://localhost/cookie.html
5.在 http://localhost/cookie.html 窗口中,單擊“設(shè)置 Cookie”按鈕。
轉(zhuǎn)載于:https://www.cnblogs.com/wangzhq/articles/450740.html
總結(jié)
以上是生活随笔為你收集整理的net中的调试javascript脚本的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 6.2-DNS系统
- 下一篇: 操作系统学习笔记-01-1.1课程概述