My problem is this, when the link is near the bottom of the page and the content of the hidden <div> extends below the bottom, I cannot scroll to see it.
I would like to adjust the top of the <div> placement if it should extend below the screen.
Below is the code I use to determine where the <div> should be displayed.
Basically I capture the current mouse position with the event listener ".onmousemove".
If the height of the <div> should exceed the available room I would like to adjust the top location d.style.top = (cY-46) + "px"; to something other than -46 from the relative position.
How can I determine the height of the dynamically created division?
And how can I determine if it is exceeding the bottom of the page?
Expand|Select|Wrap|Line Numbers
- var cX = 0; var cY = 0; var rX = 0; var rY = 0;
- document.onmousemove = UpdateCursorPosition;
- function UpdateCursorPosition(e)
- {
- cX = e.pageX; cY = e.pageY;
- }
- function AssignPosition(d)
- {
- if(self.pageYOffset)
- {
- rX = self.pageXOffset;
- rY = self.pageYOffset;
- }else if(document.documentElement && document.documentElement.scrollTop)
- {
- rX = document.documentElement.scrollLeft;
- rY = document.documentElement.scrollTop;
- }
- else if(document.body)
- {
- rX = document.body.scrollLeft;
- rY = document.body.scrollTop;
- }
- if(document.all)
- {
- cX += rX;
- cY += rY;
- }
- d.style.left = (cX+107) + "px";
- d.style.top = (cY-46) + "px";
- }
- function ShowContent(d)
- {
- if(d.length < 1)
- {
- return;
- }
- var dd = document.getElementById(d);
- AssignPosition(dd);
- dd.style.display = "block";
- }