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 6 of 6
  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Location
    Oregon, United States of America
    Posts
    882
    Thanks
    1
    Thanked 9 Times in 9 Posts

    style.posTop in Firefox

    I cannot get Firefox 2.0.0.4 to reposition an object by changing the top of posTop attribute of the objects style. This workins in IE and Safari, but not Firefox.

    Code:
    function findPos(obj) {
    	var curleft = curtop = 0;
    	if (obj.offsetParent) {
    		curleft = obj.offsetLeft
    		curtop = obj.offsetTop
    		while (obj = obj.offsetParent) {
    			curleft += obj.offsetLeft
    			curtop += obj.offsetTop
    		}
    	}
    	return [curleft,curtop];
    }
    
    function ProposalInfoRollOver(id, obj) {
    	position = findPos(obj);
    
    	floater = document.getElementById('floater_'+id);
    	floater.style.display = 'block';
    	floater.style.posTop = (position[1]+8);
    	floater.style.posLeft = (position[0]-floater.offsetWidth+1);
    }
    Any ideas?
    If I'm postin here, I NEED YOUR HELP!!

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Try

    floater.style.top = (position[1]+8);
    floater.style.left = (position[0]-floater.offsetWidth+1);
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #3
    Regular Coder
    Join Date
    Aug 2002
    Location
    Oregon, United States of America
    Posts
    882
    Thanks
    1
    Thanked 9 Times in 9 Posts
    THank you, but I have tried that. Setting those values in Firefox does nothing on my attempts.
    If I'm postin here, I NEED YOUR HELP!!

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    You also need to add position:absolute

    floater.style.position="absolute"
    Last edited by Mr J; 06-17-2007 at 09:35 AM.
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #5
    Regular Coder
    Join Date
    Aug 2002
    Location
    Oregon, United States of America
    Posts
    882
    Thanks
    1
    Thanked 9 Times in 9 Posts
    The absolute positioning has already been added in the CSS. And setting or alerting style.top, or style.posTop does not work in Firefox.

    Can anyone help?
    If I'm postin here, I NEED YOUR HELP!!

  • #6
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    posTop or posLeft will not work in Firefox

    Are you alerting style.top or floater.style.top

    Post your full code

    Here's what I've been working with and it moves the divs in Firefox

    Code:
    <script type="text/javascript">
    function findPos(obj) {
    	var curleft = curtop = 0;
    	if (obj.offsetParent) {
    		curleft = obj.offsetLeft
    		curtop = obj.offsetTop
    		while (obj = obj.offsetParent) {
    			curleft += obj.offsetLeft
    			curtop += obj.offsetTop
    		}
    	}
    	return [curleft,curtop];
    }
    
    function ProposalInfoRollOver(id, obj) {
    	position = findPos(obj);
    
    	floater = document.getElementById('floater_'+id);
    	floater.style.display = 'block';
    	floater.style.top = (position[1]+8);
    	floater.style.left = (position[0]-floater.offsetWidth+1);
    }
    </script>
    
    
    <div id="floater_1" style="position:absolute;left:50px;top:50px;width:50px;border:1px solid black" onclick="ProposalInfoRollOver(1,this)">One</div>
    <div id="floater_2" style="position:absolute;left:50px;top:100px;width:50px;border:1px solid black" onclick="ProposalInfoRollOver(2,this)">Two</div>
    <div id="floater_3" style="position:absolute;left:50px;top:150px;width:50px;border:1px solid black" onclick="ProposalInfoRollOver(3,this)">Three</div>
    Last edited by Mr J; 06-17-2007 at 11:33 AM.
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.


  •  

    Posting Permissions

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