function deleteChecked(){
var allValue="";
var j=0;
    for(var i=0;i<document.allContacts.id.length;i++){
if(document.allContacts.id[i].checked===true){
j++;
allValue=document.allContacts.id[i].value+","+allValue;
}
} if(j<document.allContacts.id.length){
var conf=confirm("Are you sure to delete these Contacts?");
if(conf=="true")
window.open("http://127.0.0.1:8080/MiniContact/delete?id="+allValue);
}
else{
var conf=confirm("Are you sure to delete all Contacts?");
if(conf=="true")
window.open("http://127.0.0.1:8080/MiniContact/delete?id=all");
}
  }
我想用JS来实现,我点击按钮触发上面的事件,方法可以执行,但是页面没动,是不是代码问题?应该怎么把页面转向SERVLET,或JSP

解决方案 »

  1.   

    function deleteChecked(){
        var allValue="";
        var j=0;
        for(var i=0;i<document.allContacts.id.length;i++){    
        if(document.allContacts.id[i].checked===true){
        j++;
        allValue=document.allContacts.id[i].value+","+allValue;
        }
        }        if(j<document.allContacts.id.length){
        var conf=confirm("Are you sure to delete these Contacts?");
        if(conf=="true")
         document.formname.action ="/delete?id="+allValue";
         document.formname.submit();
        }
        else{
        var conf=confirm("Are you sure to delete all Contacts?");
        if(conf=="true")
         document.formname.action ="/delete?id=all");
         document.formname.submit();
        }
      }
      

  2.   

    window.open()是弹出一个新窗口吧,你的浏览器是不是阻止了弹出窗口?
    还有,跳转应该是window.location