Onmouseenter和onmouseleave不使用safari浏览器

时间:2016-05-02 06:34:15

标签: jquery asp.net

Please find the attached reference image here我们无法在悬停时打开选项内的选项。它适用于除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');
    });
}

1 个答案:

答案 0 :(得分:0)

对于不匹配的引号,Safari可能更敏感。

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

转变为:

onmouseleave="mouseLeaveHandlerContextMenu('" + contextContents.id + "')"
相关问题