The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> image timeout
Sunnydog
post Jul 22 2010, 11:20 PM
Post #1


Newbie
*

Group: Members
Posts: 10
Joined: 19-July 10
Member No.: 12,334



I am having trouble trying to switch my images after a certain amount of time. here's the script:

CODE

<script type="text/javascript">
        
    <!--setTimeout("documents.images.pic1.src='pic2'",4000);-->
            
</script>


And here's the HTML:

CODE

            <div id="mainpic">

        
            <img src="pic1.jpg" alt="picture" height= "300px" width= "500px" style="margin-left: 60px; margin-top: 100px;" />


            </div>
        



User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Jul 22 2010, 11:49 PM
Post #2


WDG Member
********

Group: Root Admin
Posts: 8,331
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



Can you provide the URL (address) of a document that demonstrates the problem?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jul 23 2010, 07:35 AM
Post #3


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,804
Joined: 9-August 06
Member No.: 6



You must give the IMG a name or id named 'pic1' for that to work. Also, width and height don't use a unit in HTML (unless it's percent). It's width="500" height="300" .
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Aug 31 2010, 08:43 AM
Post #4


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,804
Joined: 9-August 06
Member No.: 6



Yes, this

CODE
setTimeout("documents.images.pic1.src='pic2'",4000);


should be

setTimeout("documents.images.pic1.src='pic2.jpg'",4000);

I.e. the URL to the new image (pic2.jpg) must be used for document.imgades.pic1.src="".
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Aug 31 2010, 12:32 PM
Post #5


.
********

Group: WDG Moderators
Posts: 8,431
Joined: 10-August 06
Member No.: 7



That should be document.images, not documents.images.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Aug 31 2010, 02:01 PM
Post #6


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,804
Joined: 9-August 06
Member No.: 6



Yeah, that too! biggrin.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 29th May 2020 - 02:48 AM