...

View Full Version : Browser crashes help!!



Guru101011
08-28-2011, 01:38 AM
Hi, i wanted to know whats wrong with this coding as its making the browser crash, firefox 5

$(document).ready(function() {

/* open rel=external in new window */
$('a[rel=external]').attr('target', '_blank');

/*Scrolling background clouds */

var offset = 600;
var offseta = 1450;

function scrollbackground() {
// decrease the offset by 1, or if its less than 1 increase it by
// the background height minus 1
offset = offset + 1;
offseta = offseta + 1;
// apply the background position
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i)))
{
$('#cloud2').css("background-position", offseta + "px top");
}
else {
$('#cloud').css("background-position", offset + "px top");
$('#cloud2').css("background-position", offseta + "px top");
}
// call self to continue animation
setTimeout(function() {
scrollbackground();
}, 100
);
}

// Start the animation
scrollbackground();

}); //end

devnull69
08-28-2011, 11:51 AM
First of all: Please use [ code ] or the # octathorpe symbol for your code. It will allow you proper indentation.

Second: Your code will increase offset and offseta indefinitely. You have no termination condition for your loop.

Old Pedant
08-28-2011, 07:01 PM
And thirdly, the code doesn't match the comment.

Comment:
// decrease the offset by 1

Code:
offset = offset + 1;
offseta = offseta + 1;

Where is there any "decrease"??



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum