Need help on this javascript issue...

Discussion in 'JavaScript' started by iMerickz, Jan 25, 2010.

  1. #1
    Hi,
    I need help on this issue.
    I am using a jvascript floating box on my site, and it works great.
    But when I try to insert another javascript code into this, it can't function properly and the browsing just can't stop to the right, becoming endless browsing to the right. Maybe it is some conflict and these 2 codes can't work together. Anyone can help? I can provide a token fee for the solution.
    PM me please..

    My site here: http://www.simplyautoblogs.com/
    The javascript floating box: http://www.jtricks.com/javascript/navigation/floating.html
     
    iMerickz, Jan 25, 2010 IP
  2. jbourne34

    jbourne34 Member

    Messages:
    94
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #2
    I'm not sure exactly what you're trying to say "the browsing just can't stop to the right, becoming endless browsing to the right"?

    Either way, make sure you keep the scripts seperate and are defining your DIV's properly. I'm guessing you have them comflicting somehow within a division in the html code, but hard to tell without the second javascript code.
     
    jbourne34, Jan 25, 2010 IP
  3. iMerickz

    iMerickz Active Member

    Messages:
    147
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    Hi thanks for your reply.
    Regarding the "endless browsing", I am trying to mean is the scrolling bar just can't stop scrolling to the right. Hmm..

    The code as below. Basically I just insert the livehelp button code into the floating bx code, all the div tags seems to be in the right place.

    <div id="floatdiv" style="
    position:absolute;
    width:180px;height:70px;left:0px;top:0px;
    padding:16px;background:#FFFFFF;
    border:2px solid #2266AA">
    Questions? Talk to us now.
    <!-- 123LIVEHELP CODE BEGIN -->
    <script language="javascript" src="http://host10.123livehelp.com/html/v50/123livehelp.php?g=simplybacklinks"></script>
    <script language="javascript">livehelp();</script>
    <!-- 123LIVEHELP CODE END -->
    </div>

    <script type="text/javascript"><!--
    /* Script by: www.jtricks.com
    * Version: 20071017
    * Latest version:
    * www.jtricks.com/javascript/navigation/floating.html
    */
    var floatingMenuId = 'floatdiv';
    var floatingMenu =
    {
    targetX: -250,
    targetY: 10,

    hasInner: typeof(window.innerWidth) == 'number',
    hasElement: typeof(document.documentElement) == 'object'
    && typeof(document.documentElement.clientWidth) == 'number',

    menu:
    document.getElementById
    ? document.getElementById(floatingMenuId)
    : document.all
    ? document.all[floatingMenuId]
    : document.layers[floatingMenuId]
    };

    floatingMenu.move = function ()
    {
    floatingMenu.menu.style.left = floatingMenu.nextX + 'px';
    floatingMenu.menu.style.top = floatingMenu.nextY + 'px';
    }

    floatingMenu.computeShifts = function ()
    {
    var de = document.documentElement;

    floatingMenu.shiftX =
    floatingMenu.hasInner
    ? pageXOffset
    : floatingMenu.hasElement
    ? de.scrollLeft
    : document.body.scrollLeft;
    if (floatingMenu.targetX < 0)
    {
    floatingMenu.shiftX +=
    floatingMenu.hasElement
    ? de.clientWidth
    : document.body.clientWidth;
    }

    floatingMenu.shiftY =
    floatingMenu.hasInner
    ? pageYOffset
    : floatingMenu.hasElement
    ? de.scrollTop
    : document.body.scrollTop;
    if (floatingMenu.targetY < 0)
    {
    if (floatingMenu.hasElement && floatingMenu.hasInner)
    {
    // Handle Opera 8 problems
    floatingMenu.shiftY +=
    de.clientHeight > window.innerHeight
    ? window.innerHeight
    : de.clientHeight
    }
    else
    {
    floatingMenu.shiftY +=
    floatingMenu.hasElement
    ? de.clientHeight
    : document.body.clientHeight;
    }
    }
    }

    floatingMenu.calculateCornerX = function()
    {
    if (floatingMenu.targetX != 'center')
    return floatingMenu.shiftX + floatingMenu.targetX;

    var width = parseInt(floatingMenu.menu.offsetWidth);

    var cornerX =
    floatingMenu.hasElement
    ? (floatingMenu.hasInner
    ? pageXOffset
    : document.documentElement.scrollLeft) +
    (document.documentElement.clientWidth - width)/2
    : document.body.scrollLeft +
    (document.body.clientWidth - width)/2;
    return cornerX;
    };

    floatingMenu.calculateCornerY = function()
    {
    if (floatingMenu.targetY != 'center')
    return floatingMenu.shiftY + floatingMenu.targetY;

    var height = parseInt(floatingMenu.menu.offsetHeight);

    // Handle Opera 8 problems
    var clientHeight =
    floatingMenu.hasElement && floatingMenu.hasInner
    && document.documentElement.clientHeight
    > window.innerHeight
    ? window.innerHeight
    : document.documentElement.clientHeight

    var cornerY =
    floatingMenu.hasElement
    ? (floatingMenu.hasInner
    ? pageYOffset
    : document.documentElement.scrollTop) +
    (clientHeight - height)/2
    : document.body.scrollTop +
    (document.body.clientHeight - height)/2;
    return cornerY;
    };

    floatingMenu.doFloat = function()
    {
    // Check if reference to menu was lost due
    // to ajax manipuations
    if (!floatingMenu.menu)
    {
    menu = document.getElementById
    ? document.getElementById(floatingMenuId)
    : document.all
    ? document.all[floatingMenuId]
    : document.layers[floatingMenuId];

    initSecondary();
    }

    var stepX, stepY;

    floatingMenu.computeShifts();

    var cornerX = floatingMenu.calculateCornerX();

    var stepX = (cornerX - floatingMenu.nextX) * .07;
    if (Math.abs(stepX) < .5)
    {
    stepX = cornerX - floatingMenu.nextX;
    }

    var cornerY = floatingMenu.calculateCornerY();

    var stepY = (cornerY - floatingMenu.nextY) * .07;
    if (Math.abs(stepY) < .5)
    {
    stepY = cornerY - floatingMenu.nextY;
    }

    if (Math.abs(stepX) > 0 ||
    Math.abs(stepY) > 0)
    {
    floatingMenu.nextX += stepX;
    floatingMenu.nextY += stepY;
    floatingMenu.move();
    }

    setTimeout('floatingMenu.doFloat()', 20);
    };

    // addEvent designed by Aaron Moore
    floatingMenu.addEvent = function(element, listener, handler)
    {
    if(typeof element[listener] != 'function' ||
    typeof element[listener + '_num'] == 'undefined')
    {
    element[listener + '_num'] = 0;
    if (typeof element[listener] == 'function')
    {
    element[listener + 0] = element[listener];
    element[listener + '_num']++;
    }
    element[listener] = function(e)
    {
    var r = true;
    e = (e) ? e : window.event;
    for(var i = element[listener + '_num'] -1; i >= 0; i--)
    {
    if(element[listener + i](e) == false)
    r = false;
    }
    return r;
    }
    }

    //if handler is not already stored, assign it
    for(var i = 0; i < element[listener + '_num']; i++)
    if(element[listener + i] == handler)
    return;
    element[listener + element[listener + '_num']] = handler;
    element[listener + '_num']++;
    };

    floatingMenu.init = function()
    {
    floatingMenu.initSecondary();
    floatingMenu.doFloat();
    };

    // Some browsers init scrollbars only after
    // full document load.
    floatingMenu.initSecondary = function()
    {
    floatingMenu.computeShifts();
    floatingMenu.nextX = floatingMenu.calculateCornerX();
    floatingMenu.nextY = floatingMenu.calculateCornerY();
    floatingMenu.move();
    }

    if (document.layers)
    floatingMenu.addEvent(window, 'onload', floatingMenu.init);
    else
    {
    floatingMenu.init();
    floatingMenu.addEvent(window, 'onload',
    floatingMenu.initSecondary);
    }

    //--></script>
     
    iMerickz, Jan 26, 2010 IP