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

Recent

Welcome to TinyPortal. Please login or sign up.

March 29, 2024, 10:19:25 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,106
  • Total Topics: 21,213
  • Online today: 358
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 120
  • Total: 120

Shoutbox Autorefresh

Started by MKJ, February 24, 2006, 03:24:19 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MKJ

The new shoutbox script is the bizz really.  No need for my auto refresh code as it has it built in.  Was set on a few minutes so I wasn't aware of it.  Me rushing into things again.  Altered the script and my site now so that it is looking ok and working ok too.  This bit of code for silent refresh of pages or scripts I found quite a long time ago and really is very useful.  No clicking on refresh and no mention of anything on the task bar.  Nothing that would annoy anyone infact.  Here is the code.  Dead simple to alter the timer as you should be able to see.


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Timer</title>
</head>

<body>

<!--compiled in <?=round(((time() + microtime()) - $GLOBALS['timer'])*1000)?> milliseconds-->
<noscript>
<!--
    We have the "refresh" meta-tag in case the user's browser does
    not correctly support JavaScript or has JavaScript disabled.

    Notice that this is nested within a "noscript" block.
-->
<meta http-equiv="refresh" content="2">

</noscript>

<script language="JavaScript">
<!--

var sURL = unescape(window.location.pathname);

function doLoad()
{
    // the timeout value should be the same as in the "refresh" meta-tag
    setTimeout( "refresh()", 5*1000 );
}

function refresh()
{
    //  This version of the refresh function will cause a new
    //  entry in the visitor's history.  It is provided for
    //  those browsers that only support JavaScript 1.0.
    //
    window.location.href = sURL;
}
//-->
</script>

<script language="JavaScript1.1">
<!--
function refresh()
{
    //  This version does NOT cause an entry in the browser's
    //  page view history.  Most browsers will always retrieve
    //  the document from the web-server whether it is already
    //  in the browsers page-cache or not.
    // 
    window.location.replace( sURL );
}
//-->
</script>

<script language="JavaScript1.2">
<!--
function refresh()
{
    //  This version of the refresh function will be invoked
    //  for browsers that support JavaScript version 1.2
    //
   
    //  The argument to the location.reload function determines
    //  if the browser should retrieve the document from the
    //  web-server.  In our example all we need to do is cause
    //  the JavaScript block in the document body to be
    //  re-evaluated.  If we needed to pull the document from
    //  the web-server again (such as where the document contents
    //  change dynamically) we would pass the argument as 'true'.
    // 
    window.location.reload( false );
}
//-->
</script>
</head>
<!--
    Use the "onload" event to start the refresh process.
-->
<body onload="doLoad()">

<script language="JavaScript">
<!--
    // we put this here so we can see something change
    document.write('<b>' + (new Date).toLocaleString() + '</b>');
//-->
</script>
</body>
</html>



Just create a new page with the above code and watch the refresh timer work silently.  You can enter this code into pages you want to refresh.  Very neat code if you ask me.

Regards.

WarBirD

When I use this, I got the Date and the Time displayed in whereever I use it. Thats almost as anoying as having a stupid countdown there. CanÂÃ,´t this be done without any text or something ? Just plain silent refresh.

ScoobyDan

WarBirD,

Simply remove this section of code from the script:
<script language="JavaScript">
<!--
    // we put this here so we can see something change
    document.write('<b>' + (new Date).toLocaleString() + '</b>');
//-->
</script>


Hey presto! Silent refreshing :D

Greenbug

What I am doing wrong here, I would like only the shoutbox to auto refresh. I added that and the whole page refreshes. Can I add this to the shoutbox code if so how?

Crip

TP-Shoutbox only refreshes when a Shout is made.. there is no auto-refresh for the shoutbox only..if ya'll want auto-refresh you'll need to look for a different shoutbox code..
Here are a few you can can in a scriptbox if you want..

- http://www.shoutmix.com/
- http://www.cj-design.com/demos/cjtagboardv3/index.php
- http://cbox.ws/getone.php
- http://txtbox.co.za/p_txtshout.php
I have become comfortably numb!

Cripzone | Crip's Free 2.0.2 Themes



Greenbug

#5
Quote from: crip on November 09, 2006, 12:19:31 PM
TP-Shoutbox only refreshes when a Shout is made.. there is no auto-refresh for the shoutbox only..if ya'll want auto-refresh you'll need to look for a different shoutbox code..
Here are a few you can can in a scriptbox if you want..

- http://www.shoutmix.com/
- http://www.cj-design.com/demos/cjtagboardv3/index.php
- http://cbox.ws/getone.php
- http://txtbox.co.za/p_txtshout.php

Thanks Crip, Ill check these out.

Please excuse my ignorance, but you cant add the above script into the native shoutbox page?

Crip

No..
you put any of those scripts in a phpbox. EZ as pie. ;)
I have become comfortably numb!

Cripzone | Crip's Free 2.0.2 Themes



RoarinRow

The http://www.shoutmix.com/ is very cool.  I like it.  It's a mini-chat/shoutbox with auto-refresh   :up:

SMF 2.0 RC3
TP 1.0 beta 5-1
Wordpress 3.0

Crip

I have become comfortably numb!

Cripzone | Crip's Free 2.0.2 Themes



akulion

by the way guys
just wanted to say
ajax shoutboxes may be very cool indeed
but they are very server heavy

so always use a ajax shoutbox which has an 'inactivity' check
meaning it checks to see if the person is even using it or not and then disables if the person dosent use it for more than X mins

also make sure guests cant see it