Results 1 to 5 of 5

Thread: Background Image Slideshow inside a Table

  1. #1
    Join Date
    Jul 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Background Image Slideshow inside a Table

    I have a question about the Background image slideshow at:

    http://www.dynamicdrive.com/dynamicindex14/bgslide.htm

    I would like to have a background image slideshow for a table, rather than the page. Is this possible?

    Thank you very much.

    Charles C. Goodin

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Yes!

    Code:
    <html>
    <head>
    <title></title>
    <style>
    #bslide {
    /*Remove below line to make bgimage NOT fixed*/
    background-attachment:fixed;
    background-repeat: no-repeat;
    /*Use center center in place of 300 200 to center bg image*/
    background-position: center;
    }
    </style>
    
    <script language="JavaScript1.2">
    
    //Background Image Slideshow- © Dynamic Drive (www.dynamicdrive.com)
    //For full source code, 100's more DHTML scripts, and TOS,
    //visit http://www.dynamicdrive.com
    
    //Specify background images to slide
    var bgslides=new Array()
    bgslides[0]="thumb2/photo1.jpg"
    bgslides[1]="thumb2/photo2.jpg"
    bgslides[2]="thumb2/photo3.jpg"
    
    //Specify interval between slide (in miliseconds)
    var speed=3000
    
    //preload images
    var processed=new Array()
    for (i=0;i<bgslides.length;i++){
    processed[i]=new Image()
    processed[i].src=bgslides[i]
    }
    
    var inc=-1
    
    function slideback(){
    if (inc<bgslides.length-1)
    inc++
    else
    inc=0
    document.getElementById? document.getElementById('bslide').background=processed[inc].src : document.all['bslide'].background=processed[inc].src
    }
    
    if (document.all||document.getElementById)
    window.onload=new Function('setInterval("slideback()",speed)')
    
    </script>
    </head>
    <body>
    <table id="bslide" height="225" width="140">
    <tr>
        <td>&nbsp;</td>
    </tr>
    </table>
    
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jul 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Thank you

    Aloha,

    Thank you very much.

    That worked very well.

    Charles C. Goodin

  4. #4
    Join Date
    Jun 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Background Image Slideshow inside a Table

    Hey,

    http://www.dynamicdrive.com/forums/a...hp/t-4103.html

    I tried its working in IE but not in Mozilla Firefox.
    Can anyone help me with that?

    Thank you,

    Koushik Gattu.

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Gee that's an old post and an even older script! Try this out:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    #bslide {
     height:225px;
     width:140px;
    }
    </style>
    <script type="text/javascript">
    
    //Background Image Slideshow- © Dynamic Drive (www.dynamicdrive.com)
    //For full source code, 100's more DHTML scripts, and TOS,
    //visit http://www.dynamicdrive.com
    
    //Specify background images to slide
    var bgslides=new Array()
    bgslides[0]="photo1.jpg"
    bgslides[1]="photo2.jpg"
    bgslides[2]="photo3.jpg"
    
    //Specify interval between slide (in miliseconds)
    var speed=3000
    
    //preload images
    var processed=new Array()
    for (i=0;i<bgslides.length;i++){
    processed[i]=new Image()
    processed[i].src=bgslides[i]
    }
    
    var inc=-1
    
    function slideback(){
    if (inc<bgslides.length-1)
    inc++
    else
    inc=0
    document.getElementById? document.getElementById('bslide').style.backgroundImage='url('+processed[inc].src+')' : document.all['bslide'].background=processed[inc].src
    }
    
    if (document.all||document.getElementById)
    window.onload=new Function('slideback();setInterval("slideback()",speed)')
    
    </script>
    </head>
    <body>
    <table id="bslide">
    <tr>
        <td>&nbsp;</td>
    </tr>
    </table>
    
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •