Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb popup floats out of screen

    Hi nerds,

    We have some problems with some javascript code.
    We are creating a new button like the ones known from addthis/sharethis and would like the same behavior as there popups.

    We have tried by putting together some different scripts, and the action is about right. We do still have one problem, and that is the position of the popup.
    If the button is placed at the right site of a website, it floats out of the screen, making scrollbars. Also it don't have same position behavior in Firefox, IE, Opera ...

    The button can be seen here: http://www.langthis.com

    The code related to this problem should bed this:
    Code:
    function move_box(an, box)
    {
        var cleft = 0;
        var ctop = 0;
        var obj = an;
    
        while (obj.offsetParent)
        {
            cleft += obj.offsetLeft;
            ctop += obj.offsetTop;
            obj = obj.offsetParent;
        }
    
    	var winW = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth;
    	var winH = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
    	
    	if (cleft+box.offsetWidth > winW) {
    		cleft = cleft - box.offsetWidth - 30;
    		if (cleft < 3)	
    			cleft = -3;
    	}
    	
    
        box.style.left = cleft + 'px';
    
        ctop += an.offsetHeight + 8;
    
        // Handle Internet Explorer body margins,
        // which affect normal document, but not
        // absolute-positioned stuff.
        if (document.body.currentStyle &&
            document.body.currentStyle['marginTop'])
        {
            ctop += parseInt(document.body.currentStyle['marginTop']);
        }
    
    	if (ctop+box.offsetHeight > winH) {
    		ctop = ctop - box.offsetHeight - 20;
    		if (ctop < 3)
    			ctop = -3;
    	}
    
        box.style.top = ctop + 'px';
    }
    If someone would be interested in rewriting the script, we would credit this in our about page. Else we would be thankful if someone just could help with the existing code.

    Best regards
    Langthis team
    Last edited by Swon; 07-26-2010 at 12:12 PM.

  • #2
    New to the CF scene
    Join Date
    Jul 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anyone?

  • #3
    New to the CF scene
    Join Date
    Jul 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    once agian

    anyone who can help?


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •