2012-09-25 20 views
1

我有IE的問題在瀏覽器的所有版本(誰不)。它適用於其他瀏覽器。IE(所有版本)以下的href,而不是執行JS

<a href="<?php echo base_url() ?>pages/delete_page/<?php echo $row->id; ?>" class="delete" data-uid="<?php echo $row->id; ?>"> 
    <i class="icon-cancel"></i><span class="delete_tooltip">delete page</span> 
</a> 

這是我的<a>標籤,它非常簡單。

基本上IE是繼href和不執行JS的。如果我從href中刪除鏈接,它會將其發送回主頁。

我使用的插件加載一個模式對話框就像我說的,一切都在每一個瀏覽器工作正常。

$('.delete').click(function(e) {  
    console.log($('#modal-'+$(this).data('uid'))); // Button which will activate our modal 
    $('#modal-'+$(this).data('uid')).reveal({    // The item which will be opened with reveal 
     animation: 'fadeAndPop',    // fade, fadeAndPop, none 
     animationspeed: 400,   // how fast animtions are 
     closeonbackgroundclick: false, // if you click background will modal close? 
     dismissmodalclass: 'modal_cancel'  // the class of a button or element that will close an open modal 
    }); 
    return false; 
}); 

這就是調用該鏈接插件的JS。

任何幫助將不勝感激。

回答

1

,這可能是一個有趣的一個...

console.log($('#modal-'+$(this).data('uid')));會導致IE異常,以便假永遠不會返回引起href執行其默認操作。

編輯: 可能在這裏造成了一些混亂。在IE中它會引起異常,因爲consoleundefined

+0

哦,非常好,謝謝。我不知道IE做到了。今天學到了一些東西。 –

+1

控制檯未在IE中定義 –

+0

@chumkiu:如果您在加載頁面之前已經開啓了開發工具,則只能在IE中定義「控制檯」。這是愚蠢的。 –

0
$('.delete').click(function(e) { 
    e.preventDefault(); 
    ... 

使用preventDefault()處理程序

http://api.jquery.com/event.preventDefault/內部參考

+1

謝謝,這可能會在未來派上用場,但我的代碼中有一個console.log ...我不知道它使IE無法正常工作。 –

相關問題