Yes, but it will take a different approach. If you want to have the
news constantly update, long after the page is initially loaded, then
you want to use an Ajax updater. The simple approach I sketched out
last night will only work if you bring the variables you want to
rotate through into the page at the initial download.
The Prototype.js library has a very useful function for this case,
called the Ajax.PeriodicalUpdater[1]. It polls a page on your server
at a frequency you define, and it also keeps track of the last
response. If the two are the same, then it adds a little decay period
to the next request, gradually widening the gap between requests (so
as to keep your server from being overwhelmed by useless requests for
the same thing). The moment that something new comes along, the check
period tightens back up to the default value.
Try this:
-
Make a script page on your server (it has to be on the same host
as your display page, or else it falls afoul of the JavaScript domain
sandbox) that will return a page fragment of the latest news items.
Maybe have it return a simple UL of linked headlines or something
like that.
-
In Freeway, draw a layer box on your page where you want this list
to appear. Put some basic text in it like “Watch this space!”. Make
note of its name in the inspector, which will become its ID.
-
Apply the Protaculous[2] action to your page and make sure the
Prototype library is selected.
-
Click the Function Body button in the Actions palette and enter
the following, substituting your news box’s ID and the name of your
server script where appropriate.
new Ajax.PeriodicalUpdater(‘yourItemId’,
‘your_script.php’,
{method: ‘get’,
frequency: 3,
decay: 2
});
These settings set the updater to poll the server every 3 seconds,
and to widen the interval by doubling it each time the response
matches the previous response. You can tinker with these values
(decay can be any positive decimal number), and you can leave them
out altogether – just include an empty pair of curly braces instead
to get the defaults (which is once a second, no decay, IIRC).
Naturally, this can only be previewed on the server. And further, to
style the contents of your list you will need to create some styles
in your page that target the list using the CSS cascade, or use
inline styles (ick) generated on your server.
Walter
- http://prototypejs.org/api/ajax/periodicalUpdater
- http://freewaypro.com/actions/downloads/Protaculous.fwactionb.zip
On Jan 24, 2008, at 4:03 AM, johnrob wrote:
Thank you, this points me in the right direction.
Is it possible to make the new ticker auto-update, without the user
having to press refresh on their browser? (I guess I’d want only
that section to auto-update, not the whole browser window).
John
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options