开发者

JQuery plugins for navigation on a page

I have developed a Jquery plugin in which a user can navigate between the ele开发者_开发技巧ments of the webpage using the arrow keys. The element currently selected ahs a highlighter around it{(highlighter div). I am specifying here the code of that part of the plugin which appear to me as if faulty

http://i.stack.imgur.com/Bnbem.png

var offset = $('.'+e.onClass).offset();
        $('#monitor').html($.htmlClean($('.'+e.onClass).html()));
        $('#highlighter').animate({'height' : $('.'+e.onClass).height() + 10, 'left' : (offset.left - 6) + 'px', 'top' : (offset.top - 10) + 'px', 'width' : $('.'+e.onClass).width() + 12 }, 300);

// here is some other code for the highlighter div

$('<div id="highlighter">')
    .addClass('highlighter')
    .prependTo('body');

    $('<div id="monitor">')
    .appendTo('body');  
    document.onkeydown = function(e) {
        var k = e.keyCode;
        if(k >= 37 && k <= 40) {
            return false;
        }
    }

//  $('body').html($.htmlClean($(this).html(), { allowedTags : ['a', 'ul', 'ol', 'li', 'br', 'p'] }));

    var toFind = 'h1, h2, h3, h4, h5, p:visible, li:visible, input, textarea, th:hasText, td:last-child, td:hasText, pre, label, dt, dd';
    $('body').find(toFind).addClass('keynav_box');
    $('body').find(toFind).keynav('keynav_focusbox','keynav_box');
    // Set the first div as the one with focus, this is optional
    $('.keynav_box:first').removeClass().addClass('keynav_focusbox');
});     
//      $('#highlighter').scrollIntoView(true);

The problem i am facing is that the navigator grows over a pretty less space and gets stuck into the top left corner as shown in the link above

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜