How do I set the 'scroll to' position in a page without using javascript?
I know how to do it with javascript, and I obviously know how to jump to a place in a page using anchors.
However, in this case, javascript is unlikely to be enabled in the browser, and the page is actually created on the fly using PHP, as opposed to being a normal HTML page with anchors embedded in it.
What I need to do as the result of a postback is to
- Create a page
- Select a point part way down it that I want scrolled into view
- Make sure that the page, when displayed in the browser, scrolls to and displays that part
How do I do that?
Setting 'scroll to' pos in PHP created page w/o javascript
Moderator: General Moderators
Re: Setting 'scroll to' pos in PHP created page w/o javascript
append #namedAnchor to the URL and redirect the browser, it will immediately jump to the named anchor on the page
Edit: hmm saw javascript is disabled, have the form post to a script, have that script output a Location header to redirect the browser
Edit: hmm saw javascript is disabled, have the form post to a script, have that script output a Location header to redirect the browser
Re: Setting 'scroll to' pos in PHP created page w/o javascript
Yes, but how, exactly? A redirect would surely be something like http://somewhere.com/mypage#myanchor, but mypage doesn't actually exist as it is script generated.have the form post to a script, have that script output a Location header to redirect the browser
Just had a thought though. The link in the original page that will cause all this would have been of the form
http://somewhere.com/myscript.php?index=12345
where 12345 tells the script how to build the page. I wonder if therefore
http://somewhere.com/myscript.php?index=12345#myanchor
or possibly
http://somewhere.com/myscript.php#myanchor?index=12345
might do it, if the script then builds the page with <a name=myanchor></a> in the appropriate place.
I'll try it.
Re: Setting 'scroll to' pos in PHP created page w/o javascript
glad i could help