2016-05-02 8 views
0

Please find the attached reference image hereホバー上のオプション内のオプションを開くことができません。 Safariを除くすべてのブラウザで動作します。もし誰かが同じことを考えているなら、私たちに知らせてください。OnmouseenterとonmouseleaveがSafariブラウザで動作しない

showContextMenu = function (contextContents) { 
    var j = 0; 
    var html = '<div onmouseenter="$(this).show();" onmouseleave="mouseLeaveHandlerContextMenu(' + contextContents.id + ')" id="contextMenu' + contextContents.id + '" class="context_menu" style="left: ' + contextContents.left + 'px; top: ' + contextContents.top + 'px"><div class="context_menu_inner">'; 
    for (var i = 0; i < contextContents.lists.length; i++) { 
     if (contextContents.lists[i].icon) { 
      j++; 
      var subMenu = contextContents.lists[i].subMenu; 
      html += '<div class="box"><div class="photo"><span class="glyphicon ' + contextContents.lists[i].icon + '"></span>' 
      + '</div><div ' + ((contextContents.lists[i].href && contextContents.lists[i].href != '') ? 'onclick="window.location.href=\'' + contextContents.lists[i].href + '\'"' : '') + ' class="text' + (contextContents.lists[i].border && contextContents.lists[i].border == true ? ' bor_bottom' : '') + '" ' + 
      (subMenu && subMenu.length > 0 ? ' onmouseleave="$(\'#contextMenu' + (contextContents.id + '' + (i + 1)) + '\').hide()" onmouseenter="showContextMenu({ id: ' + (contextContents.id + '' + (i + 1)) + ', left: $(this).offset().left + $(this).width(), top: $(this).offset().top, lists: ' + 
      JSON.stringify(contextContents.lists[i].subMenu).replace(/"/g, "\'") 
      + '})"' : '') + 
      '>' + (contextContents.lists[i].text) + 
      ((subMenu && subMenu.length > 0) ? '<span class="glyphicon glyphicon-triangle-right submenu-icon"></span>' : '') + 
      '</div></div>'; 
     } 
    } 
    html += '</div></div>'; 
    if (contextContents.id == 1) { 
     $('#contextCollection').html(html); 
    } 
    else { 
     $('#contextCollection').append(html); 
    } 

    if (j > 0) { 
     $('#contextMenu' + contextContents.id).show(); 
    } 
    $(document).on('click', function() { 
     $('#contextCollection').html(''); 
     //$(document).off('click'); 
    }); 
} 

答えて

0

恐らくSafariは、一致しない引用符の方が敏感です。

onmouseleave="mouseLeaveHandlerContextMenu(' + contextContents.id + ')" 

変更に:それ#Gerard

onmouseleave="mouseLeaveHandlerContextMenu('" + contextContents.id + "')" 
+0

この変更に取り組んでいません。 –

+0

@Vivek - 文字列をすべて英数字にするために使用される変数の値はありますか?変数を英数字の値に置き換えると、私は何の問題も見ません。 – Gerard

+0

私は同じものを変更しましたが、動作しませんでした。私の関心事は、マウスをオプションで持ってきてからオプションがホバーに来ないときです。 –

関連する問題