troubleshooting Question

Absolute Positionning Firefox

Avatar of Lefarfadais
LefarfadaisFlag for Canada asked on
CSSHTMLWeb Browsers
5 Comments1 Solution295 ViewsLast Modified:
Hello Everyone!

I ask thy wisdom to solve my problem.

I am building a website in ASP (felt mentionning it in case it could help debugging the problem) into which I have a repeater. In that repeater I have a <div> into which I have a <img> tag with different values depending to my datasource. On the event onmouseover of that tag, I need to position another div which is positionned absolute. Things works fine in Opera, Safari and IE, but in Firefox the div is showing but at point (0,0)

I've been trying multiple things but in vain.

Before you guys tells me that I shouldn't use Absolute, I need to align that div to that img, in order to show a bigger view of that image. This is the only moment i'm using the absolute positioning.

Thank you!
/*-- Javascript code --*/
function showEnlarge(picBox)
{
 
var e = document.getElementById('divImg'+picBox);
var position = {x:0,y:0};
while (e)
{
    position.x += e.offsetLeft;
    position.y += e.offsetTop;
    e = e.offsetParent;
}
    var myPic = document.getElementById(picBox)
    var myDiv = document.getElementById('bigPicDiv');
    myDiv.style.position = "absolute";
    myDiv.style.pixelTop = position.y;
    myDiv.style.pixelLeft = position.x -315;
    myDiv.style.Top = position.y;
    myDiv.style.Left = position.x -315;
    myDiv.style.width = "auto";
    myDiv.style.height = "auto";
    myDiv.innerHTML = "<img src='"+document.getElementById(picBox).src+"'/>";
}
function hideEnlarge()
{
    var myDiv = document.getElementById('bigPicDiv');
    myDiv.innerHTML = "";
}
 
/*-- HTML Code --*/
<div id="bigPicDiv" style="position:absolute;top:0px;left:0px;margin: 0 auto;"></div>
 
<!-- Repeating the following code with different id and image. This is an example of what's shown -->
<img id='1' src='http://www.somesite.com/somefile.gif' onmouseover='showEnlarge("1")' onmouseout='hideEnlarge()' />
ASKER CERTIFIED SOLUTION
random_ru

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros