If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Mar 2011
    Member #

    Im making a mock-up website for a school project and I decided to include an annoying flashing advertisement to humor my teacher (he finds this stuff funny) and to demonstrate my knowledge of "animation" using Javascript.

    Unfortunately, my knowledge is not good enough so I have to ask you.

    This is my Javascript function:

    <script type="text/javascript">

    function flash(){
    f = document.getElementById("adver").style.backgroundI mage;
    n = 1;
    f = "images/advertisement" + n + ".jpg";
    n = 2;
    f = "images/advertisement" + n + ".jpg";


    I then use: <body onload="flash()"> to make this function work.

    I am not sure if it is simply too much for the browser to handle or what, but the browser always tells me that the script has stopped running or couldnt start running properly. Is this because when the function is called, its stuck in the forever loop and cant load the rest of the page? How would I call this function otherwise?

    Thanks for your time!


  3. #2
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Not from USA
    Member #
    2783 times
    It's your while loop that's causing it. 1 will always equal one. Now, if you're going to try and rotate two ads in and out, you'll want an if condition instead.
    if(n == 1) {
    n = 2;
    } else {
    n = 1;
    Your background code here.

    And instead of using setTimeout, you can use setInterval since it will happen over and over again.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
All times are GMT -6. The time now is 06:23 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2020 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: