user1080711
user1080711

Reputation: 71

not working in chrome and opera working in mozila

(function($){
    var screen_width = 0;
    var screen_scroll = 0;
    var help_width = 0;
    var help_height = 0;

    var help_cont = '';
    var help_offset = 0;
    var help_html = '';

    var hover_status = false;

    $(".helpme").live("mouseenter",function(){
        hover_status = true;

        screen_width = $("body").width();
        screen_scroll = $(window).scrollTop();

        help_cont = $(this).attr("help");
        help_offset = $(this).offset();

        help_html = '<div id="helper_back"></div><div id="helper"><div id="helper_cont">';

     help_html += '';
     help_html += '</div></div>';

        $("body").append(help_html);
        calc_size();

        $(this).bind("mouseleave",function(){
            $("#helper_back").css("top",-9999).remove();
            $("#helper").remove();
            hover_status = false;
        });
    });

    $(document).bind("mousemove",function(e){
        if(hover_status === true) {
        calc_size();
            var local_left = e.pageX + 20;

            var local_top = e.pageY - help_height - 15;
            if(local_left + help_width > screen_width - 20) {
                local_left = screen_width - 20 - help_width;
            }
            if(local_top < screen_scroll) {local_top = e.pageY + 20};
            $("#helper_back").css("left",local_left).css("top",local_top);
            $("#helper").css("left",local_left + 3).css("top",local_top + 3);
            $("#helper_cont").css("visibility","visible");
        }
    });

    function calc_size() {
        help_width = $("#helper").width();
        help_height = $("#helper").height();
        if(help_width > 300) {help_width = 300};
        $("#helper_back").width(help_width).height(help_height);
        $("#helper").width(help_width);
    }

})(jQuery);

I've been trying to modify this code so i can build help_html with ajax. Have some problems first to read file (test.html) to string. Secondly i tried to open it in Chorme and opera not working at all. Any suggestions why is this script not working in Chrome and Opera but is working in Mozilla???

Upvotes: 0

Views: 237

Answers (2)

hlintrup
hlintrup

Reputation: 169

Also, it seems scrollTop() does not return the expected value in Chrome. Check this out (navigate to the bottom of the thread for latest replies).

Upvotes: 0

Ashkan Mobayen Khiabani
Ashkan Mobayen Khiabani

Reputation: 34150

use 'mouseover' and 'mouseout' events instead of 'mouseenter' and 'mouseleave':

Upvotes: 1

Related Questions