Jump to content

Defining Display Position For Name Anchor


wychegnome
 Share

Recommended Posts

I have a web site/page that uses fixed position divs under css control to split the page into defined areas.The top area contains the menu area and is fixed in position so that the main body sections appear to 'slide under' it as the reader scrolls down the page. Included in the main body section are named anchors to allow quick access to specific items.When the named anchor is invoked, the browser commences the display at the top of the browser window which results in the first part of the information being out of view.Is there any way of directing the browser to commence display of the named anchor section part way down the visible window - at a defined number of pixels from the top - so that the start of the section is in view.Interestingly, it works ok using Firefox to view the page direct from my hard disk (for testing), but not when it is downloaded as a live page from the web.The web page can be seen at www.keepsmiling.org.uk. It is a single page web site.Thanks.

Link to comment
Share on other sites

Scrolling a bookmarked to the top of the page is what this feature is designed to do. If a document is too short for that, the element will scroll as high as it can.There is no way to defeat this feature in pure HTML, unless you position your tags higher in the document. That will not get you pixel-perfect positioning, but it might be sufficient to your needs.You can do exactly what you want with JavaScript. You'll have to do a little math and adjust your bookmark's scrollTop value.

Link to comment
Share on other sites

Scrolling a bookmarked to the top of the page is what this feature is designed to do. If a document is too short for that, the element will scroll as high as it can.There is no way to defeat this feature in pure HTML, unless you position your tags higher in the document. That will not get you pixel-perfect positioning, but it might be sufficient to your needs.You can do exactly what you want with JavaScript. You'll have to do a little math and adjust your bookmark's scrollTop value.
Link to comment
Share on other sites

Thank you for that, it certainly works.Whilst waiting for responses I also tried window.scrollto() as an 'onClick' instruction and that produces the same effect.What I do find strange with window.scrollto() is the value in the x-axis seems to have no effect on positioning on my web page. I suppose this could be because I am using absolutely positioned divs. However, the y-axis value does enable me to scroll down to the desired position.Thank you again for your assistance.

Link to comment
Share on other sites

What I do find strange with window.scrollto() is the value in the x-axis seems to have no effect on positioning on my web page. I suppose this could be because I am using absolutely positioned divs. However, the y-axis value does enable me to scroll down to the desired position.
x would scroll horizontally. Y scrolls vertically.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...