Two simple HTML questions!

liunx

Guest
Hi there. <br />
<br />
I've got two simple questions that I'd really appreciate a little help with:<br />
<br />
(1) When loading an HTML page, how can I get the page to automatically go straight to the bottom? e.g. the HTML page is a long list, and I'd like it so that when the user enters the page, they see the bottom first, and have to scroll up to see the stuff before that (list is in chronological order).<br />
<br />
(2) What's the code to get a page to automatically refresh itself? Can this be done from PHP? Basically I an HTML guestbook that writes to an HTML file. The whole "writing thing" is fine, but I'd like to avoid the user having to press F5 after they've submitted - I'd like it to be automatic. So do I add something to the "Submit" button which will do this, or does it have to be within the PHP?<br />
<br />
Thanks in advance for any advice.<!--content-->Hi there 39steps40winks,<br />
<br />
<br />
<body onload="scrollTo(0,3000)"> just make this value as great or greater than the page height. <meta http-equiv="refresh" content="30"> value in seconds.<br />
<br />
coothead<!--content-->1. Put a named anchor at the end of the body and target it with the URL that goes to that page.<!--content-->1. That brilliant, many thanks. <br />
<br />
2. How can I attach this to the "Submit" button, so that when the form is posted to PHP, the HTML page itself automatically refreshes then, not afterv a time limit?<!--content-->2. After the form is processed forward back to the page.<br />
<br />
Page ---> PHP ---> Page<br />
<br />
The first arrow is the request, the second is the response.<!--content-->Originally posted by ray326 <br />
2. After the form is processed forward back to the page.<br />
<br />
Page ---> PHP ---> Page<br />
<br />
The first arrow is the request, the second is the response. <br />
<br />
Excuse my ignorance - I'm mainly a Flash man - but what's the code for this, assuming the page is "main.html"?<!--content-->Originally posted by 39steps40winks <br />
Hi there. <br />
<br />
I've got two simple questions that I'd really appreciate a little help with:<br />
<br />
(1) When loading an HTML page, how can I get the page to automatically go straight to the bottom? e.g. the HTML page is a long list, and I'd like it so that when the user enters the page, they see the bottom first, and have to scroll up to see the stuff before that (list is in chronological order).<br />
<br />
(2) What's the code to get a page to automatically refresh itself? Can this be done from PHP? Basically I an HTML guestbook that writes to an HTML file. The whole "writing thing" is fine, but I'd like to avoid the user having to press F5 after they've submitted - I'd like it to be automatic. So do I add something to the "Submit" button which will do this, or does it have to be within the PHP?<br />
<br />
Thanks in advance for any advice. <br />
<br />
My REPLY(ies):<br />
<br />
Question (1):- Why not try this - if this doesnt work please get back to me ------ <body onLoad="window.scrollTo(999999999,0);"><br />
<br />
Question (2):- Try this <br />
<br />
<script language="javascript"> <br />
function reload(){window.location.reload();} <br />
</script> <br />
<br />
<body onload="reload()"> <br />
<br />
The only problem with this ^^^ is that it refreshes all the time! play around with it - i am trying to right a "Once per session RELOAD/REFRESH" so that the page that the scripts in refreshes just once per session - per session being - that users browser. Duh! - Make sense? NA<!--content-->Originally posted by 39steps40winks <br />
Excuse my ignorance - I'm mainly a Flash man - but what's the code for this, assuming the page is "main.html"? <br />
I'm not a PHPer but in general the from action in main.html should be a PHP "page", say proc.php. But proc.php will ONLY emit HTML if there is an error with the form data. Otherwise it just processes the form and then does a redirect to main.html. That's a classic model-view-controller pattern for the web except it's usually expressed as JSP->servlet->JSP rather than HTML->PHP->HTML.<!--content-->Your Form should be something like this:<br />
<br />
<form action="handler.php" method="post"><br />
<br />
With handler.php being replaced with the php page your PHP code is stored on. When submit is pressed, the form goes to this page, and after the PHP code is finished doing its "writing", you should have something like:<br />
<br />
<br />
include("main.html");<br />
<br />
<br />
or<br />
<br />
<br />
header("Location: main.html");<br />
<br />
<br />
to go back to the original page.<!--content-->Better Idea. Put the content in REVERSE chronological order (newest stuff first) rather than having the document scroll down to the bottom of the page. Heck, this would save you a lot of headache.<!--content-->Which is a much more common way of posting information on the internet. When visitors return to your website, say the bookmark the page. When they return, the want to see the latest stuff first, not the oldest. But if you must, you can use:<br />
<br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"mypage.html#newest">My Page</a><br />
<br />
and where the new content is, put:<br />
<br />
<a id="newest"></a> without anything between the two tags. The problem with the <body onload="scrollTo(0,3000)"> method, is if users don't have JavaScript, or don't have it enabled, it will not work for them, not to metion, it is not exactly accessible.<!--content-->This is all really great stuff, thanks so much. MstrBob's code for the PHP file itself to contain the code to refresh after it has read / written has solved problem number 2. As for: <br />
<br />
Originally posted by PhillMc <br />
Better Idea. Put the content in REVERSE chronological order (newest stuff first) rather than having the document scroll down to the bottom of the page. Heck, this would save you a lot of headache. <br />
<br />
I tried that originally and my poor dumb readers just got really confused! Maybe I should just randomise all the messages, just to keep everyone on their toes. <br />
<br />
Many thanks again.<!--content-->One more thing - in using the "include" PHP code to refresh the screen, can I do it to a targetm frame? The PHP file is called from one frame but I want another one (called "MAIN") refreshed.<!--content-->LOL!<br />
<br />
The only way I can see people getting confused with the RC layout is if dates weren't placed with each article. If you did place the dates there, and they were still getting confused, then I wouldn't worry about them, as they are not the majority of surfers! lol :p<!--content-->Originally posted by 39steps40winks <br />
One more thing - in using the "include" PHP code to refresh the screen, can I do it to a targetm frame? The PHP file is called from one frame but I want another one (called "MAIN") refreshed. <br />
<br />
Erm, I don't think this is possible with header. Though, you might want to ask this question in the PHP forum and see if anyone else with more knowledge them myself knows for sure.<!--content-->OK, rather than PHP, is there an HTML script (or Javascript) that would, on loading, effectively load a page into a separate frame or target? E.g. similar to the META REFRESH but for another frame? Or similar to an HREF script that requires user action to load a page, but doesn't require any user action? Apologies again for my awful terminology - I'm English.<!--content-->
 
Back
Top