Remove / move the Google Chrome bottom left status bar (link address bar)

前端 未结 3 1555
天命终不由人
天命终不由人 2021-01-02 06:56

I am working on a website which is designed with a key navigation element in the lower left corner. Within Google Chrome there is a status bar on the lower left which appear

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-02 07:47

    Chrome reads the HREF attribute from your link to display the link in the status bar.

    So if you remove the HREF from your A tags, the status bar will not be displayed. However the link won't work either, :). That's why you can create an event handler on MouseOver to address that and keep your links working.

    $("body").on('mouseover', 'a', function (e) {
        var $link = $(this),
            href = $link.attr('href') || $link.data("href");
    
        $link.off('click.chrome');
        $link.on('click.chrome', function () {
            window.location.href = href;
        })
        .attr('data-href', href) //keeps track of the href value
        .css({ cursor: 'pointer' })
        .removeAttr('href'); // <- this is what stops Chrome to display status bar
    });
    

    You might run in extra issues, like disabled links or links that have other event handlers. In this case, you can tweak your selector to 'a:not(.disabled)' or perhaps just add this delegation to known elements with the css class ".disable-status", therefore your selector would be: "a.disable-status".

提交回复
热议问题