• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 357
  • Last Modified:

Cannot get alternating images to work!?

I know it's something stupid, but I can't get the following code to work in ASP.net.  Works fine if I run it in FrontPage!?

I want to alternate image files between 5 images.  I have been told not to use Flash (don't ask me why!).  Works beautifully in FrontPage testing, but does nothing in asp.net.  Any help is greatly appreciated....

Here is the code (I've left datagrids that are implemented on the same page):
<html><head><title>Javascript Rotation</title>
<script language="javascript">
var frames;
images=new Array(5);
images[0]=new Image();
images[0].src="images/5v5SoccerlogoFullcolorcopy.jpg";
images[1]=new Image();
images[1].src="images/banner-nike.gif";
images[2]=new Image();
images[2].src="images/BPM.gif";
images[3]=new Image();
images[3].src="images/flamingsoccer.jpg";
images[4]=new Image();
images[4].src="images/Header.GIF";
frames=0;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
      <HEAD>
            <title>My Title</title>
            <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
            <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
            <meta content="JavaScript" name="vs_defaultClientScript">
            <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<script language="javascript">

function animateImages()
{
   document.image_placeholder.src=images[frames].src;
   frames=(frames+1)%5;
   timeout_id=setTimeout("animateImages()",2000);
}
</script>
</head>
<body bgcolor="white" onLoad="animateImages();">
<a href="javascript:0" name="book_link">
<img src="images/5v5SoccerlogoFullcolorcopy.jpg" name="image_placeholder" border="0" width="154" height="129"></a>
</body>
</html>
0
aibar
Asked:
aibar
  • 2
1 Solution
 
hesCommented:
Try this , I moved all the Javascript to the bottom:



<html><head><title>Javascript Rotation</title>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
     <HEAD>
          <title>My Title</title>
          <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
          <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
          <meta content="JavaScript" name="vs_defaultClientScript">
          <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">

</head>
<body bgcolor="white" onLoad="animateImages();">
<a href="javascript:0" name="book_link">
<img src="images/5v5SoccerlogoFullcolorcopy.jpg" name="image_placeholder" border="0" width="154" height="129"></a>
</body>
</html>
<script language="javascript">
var frames;
images=new Array(5);
images[0]=new Image();
images[0].src="images/5v5SoccerlogoFullcolorcopy.jpg";
images[1]=new Image();
images[1].src="images/banner-nike.gif";
images[2]=new Image();
images[2].src="images/BPM.gif";
images[3]=new Image();
images[3].src="images/flamingsoccer.jpg";
images[4]=new Image();
images[4].src="images/Header.GIF";
frames=0;

function animateImages()
{
   document.image_placeholder.src=images[frames].src;
   frames=(frames+1)%5;
   timeout_id=setTimeout("animateImages()",2000);
}
</script>
0
 
aibarAuthor Commented:
That did it!  Thanks SO much.
0
 
hesCommented:
Glad to have helped
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now