Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

random file trouble

6:23 am on Apr 23, 2011 (gmt 0)

Junior Member

10+ Year Member

joined:July 4, 2007
votes: 0

Having problem with a script which should randomly load a file using jQuery's load(). The random load brings in a file with a centered background image; images are around 90KB.

It's the first function in a series, doThese(), which cycles. Currently the cycle works, but the background image part doesn't.

Safari's Web Inspector seems to show that the array of files keeps trying to load... this may be each time the cycle starts.

function doThese() {

var filename = ['file1', file2', 'file3, 'file4', file5', 'file6', 'file7', 'file8', 'file9'],
randomnumber = Math.floor(Math.random() * filename.length);

$('#back').load('loadfiles/' + filename + '.htm'); setTimeout( function() {

// setTimeout ugly but worse troubles with callback
// making the setTimeout longer to allow more loading time makes no difference

$('pre').delay(3200).animate({opacity:'0.7'}, 2400, function() {
$('#back').animate({opacity:'0.03'}, 2400, function() {
$('#back').delay(24000).animate({opacity:'1.0'}, 12000, function() {
$('pre').delay(800).animate({opacity:'1.0'}, 400, function() {
$('pre').animate({opacity:'0'}, 800, function() {
$('#back').delay(8000).animate({opacity:'0'}, 3200, doThese );
}, 3000); // end setTimeout

Hopefully it's simple.


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members