TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,966
  • Latest: safir45
Stats
  • Total Posts: 195,992
  • Total Topics: 21,323
  • Online today: 347
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 239
  • Total: 239

Auto refresh page through a block

Started by leftezi, August 05, 2011, 01:55:10 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

leftezi

Question

If i put a auto-refresh html code like this: "<meta http-equiv="refresh" content="30" >" in a block that is visible only in the forum index, will this refresh automatically the index page?
Are there any issues that can be arise?
Will this affect other pages? You understand: If this affect a post writing page would be painful.

Freddy

#1
Usually and possibly the only way to use meta tags is in the <head></head> section of the HTML.  Try it on a test site, but the page won't validate if that is a concern.

Lesmond

Here's one I found that seems to work, place in a HTML/javascript code block.

Set the block options as follows..
Frame options: Do not use title/frame styles/ Do not allow block to collapse
Choose where the block should appear. "Frontpage"

* //enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59.. I set the time 0:10 seconds, but it could be set to whatever you need*

Here is the code..

<script>
<!--

/*
Auto Refresh Page with Time script
By JavaScript Kit (javascriptkit.com)
Over 200+ free scripts here!
*/

//enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
var limit="0:10"

if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
}
function beginrefresh(){
if (!document.images)
return
if (parselimit==1)
window.location.reload()
else{
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if (curmin!=0)
curtime=curmin+" minutes and "+cursec+" seconds left until page refresh!"
else
curtime=cursec+" seconds left until page refresh!"
window.status=curtime
setTimeout("beginrefresh()",1000)
}
}

window.onload=beginrefresh
//-->
</script>


Source

leftezi

Until now i had not a setup with TP in my home server. Now i have make the setup and have done a test:

First i tried the code above from ©Lesmond. Did not work but thank you for the idea to make the box hidden.

Then i tried this simple code  "     <meta http-equiv="refresh" content="30" >     "
Is working very good. It seems that is not affect any other page. Only the Forum index page. :) :)

ZarPrime

Quote from: leftezi on August 05, 2011, 01:55:10 AM
You understand: If this affect a post writing page would be painful.

I was once working on someone's site where they had some sort of auto-refresh thing going on (this has been a while back).  Every time the page refreshed, it did indeed affect the posting page and cleared it out.  So, yes, that was a pain.  This was on an older version of SMF so if this is a concern for you, the only thing you could do is test it.

ZarPrime

leftezi

I have tested in my home server and is not affecting other pages.  :)

I have to say again, for anyone who want to do the same, that the block with the code is placed only in the page that i want to be refreshed. In my case the block is only in the forum-index page.

If someone put this in the whole site, this will bring troubles.

Lesmond

leftezi can  ask, why you want auto refresh on your front page?

leftezi

You have a P.M.

Finally with the index refresh page there is another benefit: If someone has a P.M. and has the pop up notification on, the pop up shows up in the next auto refresh!  O0

edmiller67

I am a bit of a newbie, so I hope I am not asking something obvious, but with that being an HTML code, can I just paste it into the index.php file, and if so, does it matter where in the file I place it?

Quote from: leftezi on August 05, 2011, 06:43:13 PM
You have a P.M.

Finally with the index refresh page there is another benefit: If someone has a P.M. and has the pop up notification on, the pop up shows up in the next auto refresh!  O0

ZarPrime

Hello edmiller67,

Welcome to the TinyPortal Support Site.

Quote from: edmiller67 on February 07, 2013, 04:33:52 PM
I am a bit of a newbie, so I hope I am not asking something obvious, but with that being an HTML code, can I just paste it into the index.php file, and if so, does it matter where in the file I place it?

Well, no, you can't just paste HTML code into a php file and expect it to work without turning the code into php, using echo statements and such.  If you don't want to use a hidden TinyPortal block, as Lesmond mentioned above in his post post in this topic, you would be better asking someone over at SMF how to do this.  This site is only for TinyPortal Support, not necessarily SMF Support.

ZarPrime

This website is proudly hosted on Crocweb Cloud Website Hosting.