Web Analytics Made Easy -
StatCounter Browser crashes help!! - CodingForum

Announcement

Collapse
No announcement yet.

Browser crashes help!!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Browser crashes help!!

    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


  • #2
    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.

    Comment


    • #3
      And thirdly, the code doesn't match the comment.

      Comment:
      // decrease the offset by 1
      Code:
      Code:
      offset = offset + 1;
      offseta = offseta + 1;
      Where is there any "decrease"??
      Be yourself. No one else is as qualified.

      Comment

      Working...
      X
      😀
      🥰
      🤢
      😎
      😡
      👍
      👎