This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Absolute div dynamically appended to body element Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Absolute div dynamically appended to body element " Watch "Absolute div dynamically appended to body element " New topic
Author

Absolute div dynamically appended to body element

ramnna jain
Ranch Hand

Joined: Mar 16, 2009
Posts: 129

On my web page there are hundreds of images managed in several rows.
It means it requires to scroll & scroll to view all...

On mouse move I want to show the bigger image.
I dynamically create an another div to contain the bigger image.



Using this code I append the newly created div to the body element.
The style for this div has position:absolute.

I took the coordinate with respect to the browser window & with respect to the entire document and successfully achieved the desired target on mouse over in IE.
But I am not getting the same effect in mozilla. In mozilla the div goes down at the bottom.

I want any suggestions & help to resolve the issue.

thank you
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
what is the magical code you are using to set the div's position?

Eric
ramnna jain
Ranch Hand

Joined: Mar 16, 2009
Posts: 129

To see what is the problem while opening it with Mozill, I am providing the link to the page:
http://www.dichoo.com/ramnna/myhtml.html

Just look the side scrollbar in Mozilla when you mouse over the image.


The Code:


myhtml.html





myjs.js





mycss.css



ramnna jain
Ranch Hand

Joined: Mar 16, 2009
Posts: 129

One more thing that I want to know to resolve the above problem is:

What would happen if I append new absolute positioned Div element to some static block element using appendChild
& then on mouse over change the absolute position. Would it behave differently on Mozilla & IE.

some buddy have any idea...

ramnna jain
Ranch Hand

Joined: Mar 16, 2009
Posts: 129

Hi Eric, could you please provide me any suggestion or help ...

Finding cursor position with respect to the div can also help me to solve the problem...

ramnna jain
Ranch Hand

Joined: Mar 16, 2009
Posts: 129

I searched a code to get mouse coordinate with respect to a given element.

It is returning the mouse coordinates when my mouse enters in it.
And the coordinates are calculated with respect to the top left border of the element.

It is working fine in IE but unfortunately not giving correct coordinates in Mozilla.
Here I am stating the Url & the code...

Please if any one have idea to get the correct coordinates in Mozilla..


http://www.astahost.com/info.php/Mouse-Position_t16403.html




ramnna jain
Ranch Hand

Joined: Mar 16, 2009
Posts: 129

It was really a silly mistake...

I typed:



I needed to write:



Now the code working fine on bothe the browser...

thank you...
 
 
subject: Absolute div dynamically appended to body element
 
Similar Threads
how to get location of mouse click with respect to picture?
Resizing div with drag
Get Image height and width
Mozilla on Scroll/wheel
Unwanted Scrollbars