Advanced Search

Results 1 to 3 of 3

Thread: Advanced Gallery Script

  1. #1
    Join Date
    Mar 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Advanced Gallery Script

    1) Script Title: Advanced Gallery script

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/agallery.htm

    3) Describe problem: I want to use this script, but I need the images to be centered on the page. Could you please tell me what to change/add to get the images to be centered since the images now appear on the left?

    I searched the forums but I can't find a fix that will work for this script. If I missed a post, could you please let me know.

    Thanks in advance.

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Add the highlighted in the codes:
    Code:
    <style type="text/css">
    
    .gallerycontroller{
    width: 250px;
    margin:1px auto; /*top right bottom left margin */
    }
    
    .gallerycontent{
    width: 250px;
    height: 200px;
    border: 1px solid black;
    background-color: #DFDFFF;
    padding: 3px;
    display: block;
    margin:1px auto; /*top right bottom left margin */
    }
    
    </style>
    
    <script type="text/javascript">
    
    /***********************************************
    * Advanced Gallery script-  Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * This notice must stay intact for legal use
    * Visit http://www.dynamicdrive.com/ for full source code
    ***********************************************/
    
    var tickspeed=3000 //ticker speed in miliseconds (2000=2 seconds)
    var displaymode="auto" //displaymode ("auto" or "manual"). No need to modify as form at the bottom will control it, unless you wish to remove form.
    
    if (document.getElementById){
    document.write('<style type="text/css">\n')
    document.write('.gallerycontent{display:none;}\n')
    document.write('</style>\n')
    }
    
    var selectedDiv=0
    var totalDivs=0
    
    function getElementbyClass(classname){
    partscollect=new Array()
    var inc=0
    var alltags=document.all? document.all.tags("DIV") : document.getElementsByTagName("*")
    for (i=0; i<alltags.length; i++){
    if (alltags[i].className==classname)
    partscollect[inc++]=alltags[i]
    }
    }
    
    function contractall(){
    var inc=0
    while (partscollect[inc]){
    partscollect[inc].style.display="none"
    inc++
    }
    }
    
    function expandone(){
    var selectedDivObj=partscollect[selectedDiv]
    contractall()
    selectedDivObj.style.display="block"
    if (document.gallerycontrol)
    temp.options[selectedDiv].selected=true
    selectedDiv=(selectedDiv<totalDivs-1)? selectedDiv+1 : 0
    if (displaymode=="auto")
    autocontrolvar=setTimeout("expandone()",tickspeed)
    }
    
    function populatemenu(){
    temp=document.gallerycontrol.menu
    for (m=temp.options.length-1;m>0;m--)
    temp.options[m]=null
    for (i=0;i<totalDivs;i++){
    var thesubject=partscollect[i].getAttribute("subject")
    thesubject=(thesubject=="" || thesubject==null)? "HTML Content "+(i+1) : thesubject
    temp.options[i]=new Option(thesubject,"")
    }
    temp.options[0].selected=true
    }
    
    function manualcontrol(menuobj){
    if (displaymode=="manual"){
    selectedDiv=menuobj
    expandone()
    }
    }
    
    function preparemode(themode){
    displaymode=themode
    if (typeof autocontrolvar!="undefined")
    clearTimeout(autocontrolvar)
    if (themode=="auto"){
    document.gallerycontrol.menu.disabled=true
    autocontrolvar=setTimeout("expandone()",tickspeed)
    }
    else
    document.gallerycontrol.menu.disabled=false
    }
    
    
    function startgallery(){
    if (document.getElementById("controldiv")) //if it exists
    document.getElementById("controldiv").style.display="block"
    getElementbyClass("gallerycontent")
    totalDivs=partscollect.length
    if (document.gallerycontrol){
    populatemenu()
    if (document.gallerycontrol.mode){
    for (i=0; i<document.gallerycontrol.mode.length; i++){
    if (document.gallerycontrol.mode[i].checked)
    displaymode=document.gallerycontrol.mode[i].value
    }
    }
    }
    if (displaymode=="auto" && document.gallerycontrol)
    document.gallerycontrol.menu.disabled=true
    expandone()
    }
    
    if (window.addEventListener)
    window.addEventListener("load", startgallery, false)
    else if (window.attachEvent)
    window.attachEvent("onload", startgallery)
    else if (document.getElementById)
    window.onload=startgallery
    
    </script>
    To make this work in IE, add a DTD. Try adding this above the <html> tag:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    See if it helps
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  3. The Following User Says Thank You to rangana For This Useful Post:

    Shell (03-12-2008)

  4. #3
    Join Date
    Mar 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    rangana,

    Thank you for your help. I will try it and let you know.

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
  •