PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
When a page has finished loading I can use the onload event in body to call some function.
For a process that takes time, say 5 min, what if someone clicks the stop button and I still want to trigger that onload JS function ? Anyway to get that to work ?
As far as I know/been told in the past there is nothing you can do. Stop is just that. If you could intercept this and then do things too many people would start to "disable" it.
In reality it is down to the web page design. Show something quickly if necessary. Give them a warning it may take time to process. Give messages telling them it is 10%,90% complete or whatever.
You have two time delays. PHP processing time, which should never really take that long and the time it actually takes to download (Modem speed being key here). 5 minutes php processing time is really too long for users, unless they get messages telling them something is happening. You could potentially have a waiting status bar with a Cancel process link which would link to another page informing the user that the process was cancelled. Give the user other options and they "should" ignore the stop button as their eyes are normally on your web page not the toolbar.
If Someone hits the Stop button the closing </table> tag never gets printed which is ok for a page php processes fast.
What I have is that it exracts some info from some site and displays one by one. This takes time even on servers - 2 reasons - file_get_contents and preg_match
preg_match really take time.
I am not suggesting you replace the DIV tags. The key to CSS is to remember you are separating content from format. CSS handles the style or format. The content needs to be "Tagged" to recognise the structure which is where HTML comes in. Tables unfortunately are often in the middle ground. I am not someone who says all tables should be transferred to CSS. Tables do have their place in HTML and content although not always as they are currently used, notably to format columns into columns. (Quick note here I come from a paper documentation background including SGML/XML).
For an example of a tableless design you may want to look at the following article.
Well n00b Saibot's code is a somthing new I've learnt but a couple of points to bear in mind...
1) What if javascript is not active ?
2) Still does not close the table (Although I suppose you could use javascript to close the tag but IMO you are starting to make things messy).
Yah! dat's the prob with JS. people can turn it off! I hate this feature I know it is for our own good but knowing there is a functionality/feature that will do our job easily and a great one too and not able to fully rely on its existence. Bah! makes me feel grrrr...
Thanks. It worked.
IE only ! But atleast the majority of the users will get it.
CoderGoblin wrote:Still does not close the table (Although I suppose you could use javascript to close the tag but IMO you are starting to make things messy).
Is there any other way out other than document.write("</table>"); in that onstop function ?
We will need one flush_on_stop() function in PHP.
And thanks for that CSS article.
Not as far as I know (but then I have been wrong before). You also need to check if the table has been started... What happens if the user pushes stop before the table is opened ? Shouldn't happen but users being users....