Results 1 to 2 of 2

Thread: two buttons: how can I make it work?

  1. #1
    Join Date
    Dec 2006
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default two buttons: how can I make it work?

    1) Script Title: java script
    2) Describe problem: There is two buttons , I need them do same function:mouseover and box with 3pics(fade effect) pop-up.
    in my script only one button works that way. Other one don't.
    What is wrong in my script?

    Thank you in advance.

    <html>
    <head>
    <title>Untitled</title>
    <script language="JavaScript">
    <!--
    function FP_swapImg() {//v1.0
    var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
    n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
    elm.$src=elm.src; elm.src=args[n+1]; } }
    }

    function FP_preloadImgs() {//v1.0
    var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
    for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
    }
    function FP_getObjectByID(id,o) {//v1.0
    var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
    else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
    if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
    for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
    f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
    for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
    return null;
    }
    // -->
    </script>
    </head>
    <script language="JavaScript">
    function showImage(divID,action){
    objDiv = document.getElementById(divID);
    objDiv.style.display = 'block';
    if(action==1){
    objDiv.style.display = 'block';
    }else{
    objDiv.style.display = 'none';
    }
    }
    </script>
    <script type="text/javascript">

    var fadeimages=new Array()
    //SET IMAGE PATHS. Extend or contract array as needed
    fadeimages[0]=["montenegro%20024.jpg", ""] //plain image syntax
    fadeimages[1]=["montenegro%20062.jpg", ""] //image with link syntax
    fadeimages[2]=["montenegro%20106.jpg", ""] //image with link and target syntax

    //SET IMAGE PATHS. Extend or contract array as needed
    fadeimages[0]=["montenegro%20024.jpg", ""] //plain image syntax
    fadeimages[1]=["montenegro%20062.jpg", ""] //image with link syntax
    fadeimages[2]=["montenegro%20106.jpg", ""] //image with link and target syntax

    var fadebgcolor="#E0FFFF"

    ////NO need to edit beyond here/////////////

    var fadearray=new Array() //array to cache fadeshow instances
    var fadeclear=new Array() //array to cache corresponding clearinterval pointers

    var dom=(document.getElementById) //modern dom browsers
    var iebrowser=document.all

    function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
    this.pausecheck=pause
    this.mouseovercheck=0
    this.delay=delay
    this.degree=10 //initial opacity degree (10%)
    this.curimageindex=0
    this.nextimageindex=1
    fadearray[fadearray.length]=this
    this.slideshowid=fadearray.length-1
    this.canvasbase="canvas"+this.slideshowid
    this.curcanvas=this.canvasbase+"_0"
    this.theimages=theimages
    if (typeof displayorder!="undefined")
    this.theimages.sort(function() {return 0.5 - Math.random();})
    this.imageborder=parseInt(borderwidth)
    this.postimages=new Array() //preload images
    for (p=0;p<theimages.length;p++){
    this.postimages[p]=new Image()
    this.postimages[p].src=this.theimages[p][0]
    }

    var fadewidth=fadewidth+this.imageborder*2
    var fadeheight=fadeheight+this.imageborder*2

    document.write('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')

    if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
    this.startit()
    else{
    this.curimageindex++
    setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
    }
    }

    function fadepic(obj){
    if (obj.degree<100){
    obj.degree+=10
    if (obj.tempobj.filters&&obj.tempobj.filters[0]){
    if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
    obj.tempobj.filters[0].opacity=obj.degree
    else //else if IE5.5-
    obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
    }
    else if (obj.tempobj.style.MozOpacity)
    obj.tempobj.style.MozOpacity=obj.degree/101
    else if (obj.tempobj.style.KhtmlOpacity)
    obj.tempobj.style.KhtmlOpacity=obj.degree/100
    else if (obj.tempobj.style.opacity&&!obj.tempobj.filters)
    obj.tempobj.style.opacity=obj.degree/101
    }
    else{
    clearInterval(fadeclear[obj.slideshowid])
    obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
    obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
    obj.populateslide(obj.tempobj, obj.nextimageindex)
    obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
    setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
    }
    }

    fadeshow.prototype.populateslide=function(picobj, picindex){
    var slideHTML=""
    if (this.theimages[picindex][1]!="") //if associated link exists for image
    slideHTML='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'
    slideHTML+='<img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
    if (this.theimages[picindex][1]!="") //if associated link exists for image
    slideHTML+='</a>'
    picobj.innerHTML=slideHTML
    }


    fadeshow.prototype.rotateimage=function(){
    if (this.pausecheck==1) //if pause onMouseover enabled, cache object
    var cacheobj=this
    if (this.mouseovercheck==1)
    setTimeout(function(){cacheobj.rotateimage()}, 100)
    else if (iebrowser&&dom||dom){
    this.resetit()
    var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
    crossobj.style.zIndex++
    fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
    this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
    }
    else{
    var ns4imgobj=document.images['defaultslide'+this.slideshowid]
    ns4imgobj.src=this.postimages[this.curimageindex].src
    }
    this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0
    }

    fadeshow.prototype.resetit=function(){
    this.degree=10
    var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
    if (crossobj.filters&&crossobj.filters[0]){
    if (typeof crossobj.filters[0].opacity=="number") //if IE6+
    crossobj.filters(0).opacity=this.degree
    else //else if IE5.5-
    crossobj.style.filter="alpha(opacity="+this.degree+")"
    }
    else if (crossobj.style.MozOpacity)
    crossobj.style.MozOpacity=this.degree/101
    else if (crossobj.style.KhtmlOpacity)
    crossobj.style.KhtmlOpacity=this.degree/100
    else if (crossobj.style.opacity&&!crossobj.filters)
    crossobj.style.opacity=this.degree/101
    }

    fadeshow.prototype.startit=function(){
    var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
    this.populateslide(crossobj, this.curimageindex)
    if (this.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
    var cacheobj=this
    var crossobjcontainer=iebrowser? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
    crossobjcontainer.onmouseover=function(){cacheobj.mouseovercheck=1}
    crossobjcontainer.onmouseout=function(){cacheobj.mouseovercheck=0}
    }
    this.rotateimage()
    }

    </script>


    <body onload="FP_preloadImgs(/*url*/'buttonC1.jpg',/*url*/'buttonC2.jpg',/*url*/'buttonCF.jpg',/*url*/'buttonD0.jpg')">


    <br>
    <img border="0" id="img1" src="buttonCE.jpg" height="20" width="100" alt="Button Text"
    onmouseover="showImage('ImagesArea',1)"
    onmouseout="showImage('ImagesArea',0)"
    onclick="open_win('http://www.yahoo.com')"</a></div>

    <br>
    <div id="ImagesArea" style="border:2px solid #4682B4;width:150px;height:100px;display:none">
    <table width="100%">
    <tr>
    <td align="center"><script type="text/javascript">
    new fadeshow(fadeimages, 150,150, 1, 1000, 9)
    </script></td>
    </tr>
    </table>
    </br>
    </div>
    <div style="position: absolute; width: 150px; height: 150px; z-index: 1; left: 291px; top: 78px" id="layer1">
    <img border="0" id="img1" src="buttonCE.jpg" height="20" width="100" alt="Button Text"
    onmouseover="showImage('ImagesArea',2)"
    onmouseout="showImage('ImagesArea',0)"
    onclick="open_win('http://www.google.com')"</a></div>
    <br>
    <div id="ImagesArea" style="border:2px solid #4682B4;width:150px;height:150px;display:none">
    <table width="100%">
    <tr>
    <td align="center"><script type="text/javascript">
    new fadeshow(fadeimages, 150,150, 0, 1000, 3)
    </script></td>
    <script type="text/javascript">
    function open_win(url)
    {
    window.open(url)
    }
    </script>
    </tr>
    </table>

    </div>
    </body>
    </html>

    Last edited by lelu; 01-08-2007 at 06:56 PM.

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Warning: Please edit your post to conform to the guidelines when posting a DD scripts related question. See this thread for the proper posting format when asking a question.

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
  •