Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - showDropDown
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

showDropDown

 Post Reply Post Reply Page  12>
Author
Hydrogen View Drop Down
Newbie
Newbie
Avatar

Joined: 25 January 2005
Location: United Kingdom
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote Hydrogen Quote  Post ReplyReply Direct Link To This Post Topic: showDropDown
    Posted: 23 July 2007 at 6:16pm
I'm having some trouble with this both in IE and Firefox.

Whenever the drop down menu is called the pop-up is always a long way to the right, and futher down than it should be...

My entire forum is contained in a container DIV which is positioned relatively.  But looking at the showDropDown script, it should work I thought.

(getOffsetLeft(parentElement) and (getOffsetLeft(parentElement) both return the correct position of the link that calls the script, yet the pop-ups are placed in odd places.

any ideas?


Back to Top
Hydrogen View Drop Down
Newbie
Newbie
Avatar

Joined: 25 January 2005
Location: United Kingdom
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote Hydrogen Quote  Post ReplyReply Direct Link To This Post Posted: 26 July 2007 at 6:16pm
Just an update for anyone that may have a similar problem...

I solved this by adding some lines to getOffsetLeft(elm) and getOffsetTop(elm).  The problem was that my site is surrounded by DIVs, and I needed the position from the element to the DIV, not from the elemnet to the BODY tag.

I included some new variables in the loop which adds up the distance, they are to store the two previous results given, then to pass the oldest result back to 'showDropDown'.

a messy way of doing it... but I couldn't think of a way to stop:
    while(mOffsetParent){

two loops before it became a null value.


Back to Top
odang View Drop Down
Newbie
Newbie


Joined: 02 April 2006
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote odang Quote  Post ReplyReply Direct Link To This Post Posted: 02 August 2007 at 12:34pm
could you please either post or PM the code to correctly align the dropdowns?  I have the exact same issue.
Back to Top
Hydrogen View Drop Down
Newbie
Newbie
Avatar

Joined: 25 January 2005
Location: United Kingdom
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote Hydrogen Quote  Post ReplyReply Direct Link To This Post Posted: 03 August 2007 at 12:02pm
Well it turns out it never worked in IE.  I don't have the code anymore but it was something like...


function getOffsetLeft(elm){
    var mOffsetLeft = elm.offsetLeft;
    var mOffsetParent = elm.offsetParent;
    var SecondtoLast;
    while(mOffsetParent){
        SecondtoLast = mOffsetLeft;
        mOffsetLeft += mOffsetParent.offsetLeft ;
        mOffsetParent = mOffsetParent.offsetParent;
    }
    return SecondtoLast;
}


anyone any ideas why this wouldn't work in IE? It DOES return the correct value... BUT IE still positions it in relation to the window... not the DIV. (the div is set up correctly, everything I position : absolute;... end up in the top left corner of it, apart from this dropdown. GRRR Wacko

Back to Top
Mikey View Drop Down
Senior Member
Senior Member

1979

Joined: 06 October 2003
Location: United Kingdom
Status: Offline
Points: 839
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mikey Quote  Post ReplyReply Direct Link To This Post Posted: 05 August 2007 at 9:00pm
I'm looking into this as well as i always place my forum in a seperate DIV so it slots in with my website.

Strangley enuff the styling is also all wrong on the links with drop down menus...

For example... http://skatenstone.co.uk/testforum/default.asp
Handyman man?
Back to Top
Hydrogen View Drop Down
Newbie
Newbie
Avatar

Joined: 25 January 2005
Location: United Kingdom
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote Hydrogen Quote  Post ReplyReply Direct Link To This Post Posted: 05 August 2007 at 11:03pm
I'm still no further forward on it myself, but the site is coming together and it needs sorting.

so, I have two options....

place a DIV around every single place that I need a popup and position the popup absolutley...

or.. carry on thinking about it...

I'm no cross browser tag genius or anything but, is there nothing we could do using LayerX and LayerY properties?
Back to Top
Hydrogen View Drop Down
Newbie
Newbie
Avatar

Joined: 25 January 2005
Location: United Kingdom
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote Hydrogen Quote  Post ReplyReply Direct Link To This Post Posted: 09 August 2007 at 7:15pm
UPDATE!

I've devised a better solution!

Simply work out the distance of your container DIV from the left of the body.

Here is the edit I made to 'function ShowDropDown'... this works for me, where my container DIV is called 'containername'.


    var mOffsetContainer = document.getElementById('containername')
    mOffsetC = mOffsetContainer.offsetLeft;
    dropDownElement.style.left = (getOffsetLeft(parentElement) - offSetRight - mOffsetC) + 'px';
    dropDownElement.style.top = (getOffsetTop(parentElement) + parentElement.offsetHeight - 3) + 'px';

Back to Top
Mikey View Drop Down
Senior Member
Senior Member

1979

Joined: 06 October 2003
Location: United Kingdom
Status: Offline
Points: 839
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mikey Quote  Post ReplyReply Direct Link To This Post Posted: 10 August 2007 at 12:35am
Nice, i'll give this a go later and report back Thumbs%20Up
Handyman man?
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.