15-奇怪的Js文件引用问题
JS文件的內容:
/*
*/
function HaveCheck(message)
??? {
???? var a=document.all.gvAccount;
???? var count=0;
???? if(a!=null)
???? {
????? for(i=0;i<a.rows.length;i++)
????? {
?????? for(j=0;j<a.rows[i].cells[0].children.length;j++)
?????? {
??????? var var1=a.rows[i].cells[0].children[j];
??????? if(var1.tagName=="INPUT" )
??????? {
???????? if(var1.type=="checkbox")
???????? {
????????????? if (var1.checked)
????????????????? count=count+1;
???????? }
??????? }
?????? }
????? }??
??? }
??
??
????? if(count==1)
????? {
????????? //window.alert(message);
????????? if(message != null)
????????????? {
????????????? return window.confirm(message);
????????????? //window.alert("test");
????????????? //return true;
????????????? }
????????? else
????????????? {
????????????? //window.alert("ssssnull");
????????????? return true;
????????????? }
????? }
????
??? else
????? {??
????????? window.alert("Only one can be choosing.Please try again.");
????????? return false;
????? }
??? }
按紐與JS中事件的綁定代碼:
btnEdit.Attributes.Add("onclick", "Javascript:return HaveCheck('Are you sure to edit this request?');");
按紐事件代碼:
protected void btnEdit_Click(object sender, EventArgs e)
????? {
???????????? Response.Write("test");
????? }
引用JS文件的代碼:
1)<script language= "Javascript" src="js/checkbox.js" type="text/javascript" ></script>
此時一切正常,當我不選任何選項或者多選(count==1)的時候,提示"Only one can be choosing.Please try again".只選一項的時候,執行了詢問代碼,而且也執行了Response.Write("test")這句;
2)<script language= "Javascript" src="js/checkbox.js" type="text/javascript" />
此時一半正常,當我不選任何選項或者多選(count==1)的時候,提示"Only one can be choosing.Please try again".只選一項的時候,執行了詢問代碼,但是沒有執行Response.Write("test")這句;
轉載于:https://www.cnblogs.com/zerobug/archive/2008/05/18/1201949.html
總結
以上是生活随笔為你收集整理的15-奇怪的Js文件引用问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 民生银行如意宝怎么没有收益
- 下一篇: [推荐]SharePoint开发WebC