2014-01-29 118 views
0

我很抱歉這篇文章,但我不明白爲什麼我的代碼不工作。我在表格的每一行和表格頂部都有一個編輯按鈕。我想選擇一行並希望通過單擊編輯按鈕進行編輯。請在其他情況下查看我的代碼。我試過 window.location,window.location.replace,window.location.href但沒有任何工作。請幫忙。在javascript中重定向頁面

$('#lc_edit_btn').click(function(){ 

      var countchecked = $('table input[type="checkbox"]').filter(":checked").length; 

       if(countchecked<1){ 
        alert('You didn\'t select any item.'); 

       }else if(countchecked>1){ 

        alert('You can can not edit more than one item at a time.'); 

       }else{ 

        window.location = "http://<?php echo base_url();?>lc/edit"; 
        // similar behavior as an HTTP redirect 
        window.location.replace("http://<?php echo base_url();?>lc/edit"); 

        // similar behavior as clicking on a link 
        window.location.href = "http://<?php echo base_url();?>lc/edit"; 
       } 
     }); 
+0

交叉檢查其是否在你的其他或不來了。 也爲http:// <?php echo base_url();?> lc/edit –

+0

打印值'console.log(「http:// <?php echo base_url();?> lc/edit」);檢查你的瀏覽器控制檯!!!!!!! – rynhe

+0

可能你會從http://stackoverflow.com/questions/503093/how-can-i-make-a-redirect-page-in-jquery-javascript – Syd

回答

0

試試這個:

window.location = "http://" + <?php echo base_url();?> + "lc/edit";