Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8547613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:18:12+00:00 2026-06-11T13:18:12+00:00

This is the JavaScript portion of my assignment website – it should display a

  • 0

This is the JavaScript portion of my assignment website – it should display a dating ad and on interval move it around the screen, and at each interval it loads a new image

It will randomly move horizontally, but won’t move vertically. This problem happens in Firefox – in IE it has no problem.

However in IE it won’t iterate over the images, but it does in Firefox.

Could anyone tell me what’s going on?

<script type="text/javascript">
    var rotatingAd = new Array(3);
    var curPosition = 1;
    var screenWidth = 0;
    var screenHeight = 0;

    for(var i = 0; i < 4; ++i) 
    {
        rotatingAd[i] = new Image();

        rotatingAd[i].src = "AdDate" + i + ".gif";

    }
    function openOrderForm()
    {
        window.open("order.html");
    }



    function moveAd(){
    var leftPos = getRandomLeft();
    var topPos = getRandomTop();
    document.getElementById("AdDate").style.top = topPos; + "px";//this is where firefox says the css error is 

          document.getElementById("AdDate").style.left = leftPos + "px";
    if(curPosition == 3)
    {
        curPosition = 0;
    }
    document.AdDatePic.src = rotatingAd[curPosition].src;//this is where IE gets its null error from    
    curPosition++;

}

    function start(){
  screenWidth = document.body.clientWidth;
  screenHeight= document.body.clientHeight;
  //alert("width="+screenWidth + "height="+screenHeight)
 //setTimeout("moveAd()", 3000);
  setInterval("moveAd()", 2000);
}

    function getRandomLeft(){
     var lpos;
     lpos = Math.floor(Math.random()*(screenWidth -400));
     return lpos;
    }

    function getRandomTop(){
     tpos = Math.floor(Math.random()*(screenHeight - 135));
      return tpos;
    }
</script>
<body onload="start();">
<span id="AdDate" style="position:absolute; left:300px; top:300px;" >
  <img id="AdDatePic" src="AdDate0.gif" alt="picture of gopher"   />
</span>
</body>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:18:13+00:00Added an answer on June 11, 2026 at 1:18 pm

    It looks like your issue with IE is related to how your trying to select the picture tag

    changing your code to

    document.getElementById("AdDatePic").src

    from

    document.AdDatePic.src
    

    should fix the IE issue

    The firefox issue is from semicolon placement

    topPos + "px;"
    

    should fix the issue

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This a small portion of the javascript code I used for an HTML5 music
This Javascript code is using the 'this' keyword inside a nested function (which is
This javascript function takes JSON and formats it to XML. The data is a
This javascript code does not work in IE8, but works in Firefox and Google
This javascript will find all my selects and validate them but I want to
Given this JavaScript code (which is just a comment referring to a url): //
With this javascript I'm printing list of records: <script type=text/javascript> $(document).ready(function(){ function hide(){ $('#friend_list').fadeIn(100);
I have this Javascript/JQuery code: <script type=text/javascript src=http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js></script> <script type=text/javascript> name = $(#name).val(); alert(Name:
I have this Javascript function that sends username and password to php file through
I have this Javascript: <script language=javascript type=text/javascript> $().ready(function() { $('#ex2').jqm({ajax: 'view.php?id=<?=$objResult[id];?>', trigger: 'a.ex2trigger'}); });

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.