function moveline(){
                var box_width=80;
                var box_top=60;
                
                var current_cursor_x=event.clientX;
                var current_cursor_y=event.clientY;
                var line_in=current_cursor_x-div_left;
                var top_in=current_cursor_y-div_top;
                if(line_in>=left_blank&&line_in<=(width-right_blank)){//控制边界
                    //线跟随
                    line1.style.left=line_in-left_blank;
                    //框跟随
                    var x_value_temp=cal_x(line_in);
                    var x_index=get_x_index(x_value_temp);
                    msg_box.innerHTML="<p><font size=2>&nbsp;"+find_x(x_index)+"</font><br><font size=2 color='blue'>&nbsp;"+find_y(x_index)+"</font>";
                    
                    if(line_in<width-right_blank-box_width-10){
                        msg_box.style.left=line_in+5;
                    }else{
                        msg_box.style.left=line_in-box_width;
                    }
                    
                    if(top_in>=top_blank&&top_in<=(height-bottom_blank)){
                        if(top_in<=height-bottom_blank-box_top-10){
                            msg_box.style.top=top_in;
                        }else{
                            msg_box.style.top=top_in-box_top;
                        }
                    }
                }    
            }
当width超过2000(估计值)后,该函数无效.请大家帮忙分析一下是怎么回事
具体情况是:有一个页面,X轴滚动条很长,在显示屏幕范围内有正常使用该函数,超过屏幕一定范围后该函数就无效了

解决方案 »

  1.   

    if(line_in>=left_blank&&line_in<=(width-right_blank)){//控制边界
    上面的想加成红色失败
    很少发这样的帖子,经验问题,又无法修改,原代码是:
    if(line_in>=left_blank&&line_in<=(width-right_blank)){//控制边界
      

  2.   

    在一个DIV里面使用event.clientX会不会有问题?
    DIV很长..有很长的滚动条
      

  3.   

    clientX 不会超过屏幕的分辨率的.要加上scrollLeft
      

  4.   


    clientX Property  Sets or retrieves the x-coordinate of the mouse pointer's position relative to the client area of the window, excluding window decorations and scroll bars.
      

  5.   

    event.clientX + document.body.scrollLeft; 
    event.clientY + document.body.scrollTop;