PDA

View Full Version : Random Iframe Content



Finger Tips
10-28-2005, 12:11 AM
I am using the Random Iframe content script. How can I get it to follow a particular order. When I go in and out of the page several times I will get the same content 3 out of 5 times.

jscheuer1
10-28-2005, 04:36 AM
Random means random. Anything can happen and the odds are exactly the same for any given occurrence each time you 'roll the dice'. To get a random script to avoid repeats, I usually test that the new random generated value is different than the last used or current value. To do this onload though would require that a cookie be set to hold the old value and then evaluated on the next load. Another approach is to have so many unique possible outcomes that repetition becomes less likely. Say you currently have three possibles, repetition is highly likely. If you have 10 or 20, it becomes less likely.

whatever
.

hobwebs
02-07-2006, 05:45 PM
I too am using the Random Iframe Content script http://www.dynamicdrive.com/dynamicindex17/randomiframe.htm

Although there are 10 different 'panels' that are called randomly at http://www.computersplus.co.uk, I find that there is a lot of repetition. I do understand that this is normal but I would like to know how the script could be modified to read a cookie as mentioned previously.

Unfortunately I know almost nothing about Javascript and DHTML but I do know how to cut and paste! :D

jscheuer1
02-08-2006, 07:42 AM
Well, you have to realize that you are looking at this from the site owner's and/or designer's perspective. The user will see content that, as far as they know, is hard coded onto the page, if it changes sometimes and other times remains the same, it will make little difference to them. If they frequent the page, eventually they will see all (10 was it?) of the possible content portions. This script should not be relied upon as a means to display all of the items. If that is your object, there should be a separate page with all the items on it and a link provided to it from this page. In fact, you could make it so that clicking on any individual item in the iframe will load a page with all items on it with the one that was clicked on at or near the top with its expanded information, on this page, clicking on any item could collapse the previous item's details and expand the current item's. There are a number of scripts* here at DD (via the main DD site) and elsewhere that do this. If you need help locating them here at DD, let me know.

Getting back to the repetition thing. Code could be added that will check to see if the content about to be displayed is the one that just was displayed but, this will require a cookie and cookie code to support it. Even if you were to institute such a scheme, it could happen that, if not an immediate repeat, you could have the one that showed the time before that. It is hardly worth it under the circumstances. To avoid this, the cookie and checking code could be made to list each content viewed and only show one of the ones not seen yet, until all have been viewed then clear itself and start over. However, if a user clears cookies or uses a different browser, this will not work. Also, if a user is interested in a particular item, it will become very unlikely that it will ever appear again for them within a reasonable period of time.

I would recommend, as I said, leaving things as they are and providing a link to the full item listings on another page.

*Search the main site for 'expandable content' and 'switch content'.

hobwebs
02-09-2006, 05:51 PM
Thanks jscheuer1,
You are absolutely right of course in that we are looking at it from a designer/owner perspective. I will leave it as is for now.

The thing that concerns me is whether or not search engines would perceive this as 'changed content' since we are calling up iFrames containing html files themselves. Would we be better off using something like ajax or server side includes with content that changes with each day of the week etc.
The thing is we want to keep the homepage 'fresh' without having to add stuff every day if you know what I mean.

jscheuer1
02-09-2006, 06:44 PM
I'm not up on the latest 'skinny' on search engines and what they supposedly like or dislike. As far as I know though, as long as the changing content is also available via a regular link, it will still be spidered and included. If your goal is to appear different each time to the search engine spiders, I don't think this script will not do that. Spiders, to the best of my knowledge, ignore javascript. Best, I would think, to have one page hard coded as the source of the iframe so the spiders (and non-javascript enabled browsers) will see that page. It could even be a page with all of the items on it.