/    Sign up×
Community /Pin to ProfileBookmark

Auto Positioning of div window

In my project on hovering the mouse link over some person’s name it is showing the mini profile of that person in div window .It is being done through Ajax but i want to auto position that div window so it shows the mini profile everytime regardless of the position of person’s name. Is there any way?
Thanks

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceJun 22.2006 — Yes, you can base the DIV position upon the mouse coordinates -- as gleaned from the [B]event[/B] object. The event object should be passed to your function from the [b]onmouseover[/b] event:

onmouseover="return ShowProfile(event)"

If the function, you can test as to which event object you received -- IE vs. non-IE:

if(window.Event) {

//non-IE

} else {

// IE

}

[URL=http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_event.asp]IE Event Object[/URL]

[URL=http://www.georgehernandez.com/h/xWebs/DOM/Events/EventObject.htm]NS-compatible Event Object[/URL]
Copy linkTweet thisAlerts:
@AjaxNoviceauthorJun 22.2006 — I had already done that but if the person's name is at the bottom of the window then on hovering mouse over that person's name would cause the div window to open but it will not show all the contents in div window.For example in windows when we right click on desktop at the bottom then menu will adjust its position & open above mouse position, while right clicking at the top will cause it to open below the mouse position.So i want to implement such kind of auto positioning in my project.Is there any way.

Thanks
Copy linkTweet thisAlerts:
@phpnoviceJun 22.2006 — y1 = the calculated top position of the DIV layer

h1 = the height of the DIV layer ([B]offsetHeight[/B])

y2 = the scrolled top position of the document ([B]scrollTop[/B])

h2 = the height of the document viewing area ([B]offsetHeight[/B])

if ((y1 + h1) > (y2 + h2)) y1 = (y2 + h2) - h1;
×

Success!

Help @AjaxNovice spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...