SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Jul 2006
    Location
    Fionnphort, Isle of Mull, Scotland
    Posts
    348
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Preventing automatic scroll to top when 'unhiding' hidden content

    On a page I'm developing for a client http://webadit.co.uk/cakelady/?page=weddingrange# I have three hidden 'slide-shows' which are made to appear by clicking one of the headings (currently shown in brown colour).

    My problem is that when any slide-show appears, the page scrolls to the top. This is OK for the first two, but the third slideshow always appears off-screen, so the visitor won't see it unless they scroll down.

    I've tried putting
    Code:
    window.scrollTo(0,600);
    into the JS function, but it seems to get ignored*, and
    Code:
    alert ("Screen Top = " + window.screenY);
    always gives the answer '-4'. Just by way of a test I've put the same scroll command to run on page load, and it seems to work there (not shown in the example in the link).

    *I don't think it's actually ignored, it seems to work and then get over-ruled.

    When the example runs there are some 'alert' messages, the first of which isn't directly relevant, but serves to stop the action. After this is dismissed the page scrolls as required, but the next alert shows '-4', and when that's dismissed the page scrolls to the top, exactly what I do not want !

    I'm testing in Firefox 8. I've not tried elsewhere yet.

    Can anyone help with this problem, please ?
    Tim Dawson
    Isle of Mull, Scotland

  2. #2
    SitePoint Addict
    Join Date
    Jul 2006
    Location
    Fionnphort, Isle of Mull, Scotland
    Posts
    348
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The solution wasn't all that difficult in the end. I got the solution from the JQuery forum.
    I just needed to add "return false" to the onclick event handlers. Works a treat.
    Tim Dawson
    Isle of Mull, Scotland


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •