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,982
  • Total Topics: 21,320
  • Online today: 844
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 487
  • Total: 487

Shoutbox Autorefresh?

Started by MKJ, February 23, 2006, 08:47:18 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MKJ

You can see the shoutbox by clicking on the very left arrow next to the red Home button. 

borgBOB

Thanks, it is a good code snippet, And I will move it there.

borgBOB

Quote from: MKJ on February 24, 2006, 03:24:19 AM
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.

MKJ

A little update on this.  I will use this shoutbox throughout my site so there could be multiple instances running if someone - like me - runs a few windows at the same time.  Noticed today that the refresh that works with the script does click and shows on the task bar.   I have now disabled the refresh in the config.php file and added the silent refresh code to the display.php file - right at the bottom.  I have set it to 30 seconds refresh which should be ok for most users including dial up.  Much better without any annoying clicks.  I should be able to put a link outside of the box too so that manual refresh could be used. 

crip

You could have put C-J Tagboard in a HTML box using the htmlcode.dat, but anyway you like it...do you like the Xtra's? :)

MKJ

Yeah - very neat script.  I am adding it to my weblogs now so everyone can chat away.  Getting good this.  Will also be updating the weblogs so that users can have their own galleries and file updates - along with a Media Player (though I have to ask my internet host provider about this as the player can show mp3 etc which they are not keen on hosting).

By the way because I am showing this shoutbox in an iframe it can be used on anyone's site.  Be able to chat away between websites.

This website is proudly hosted on Crocweb Cloud Website Hosting.