dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: Hide Images - HELP

  1. #1
    Join Date
    Nov 2012
    Posts
    1

    Question Hide Images - HELP

    Hello everyone,

    I'm trying to create a function to the below script that will allow me to hide the images if one of them is clicked on, any help would be greatly appreciated.

    <script type="text/javascript">
    var snowmax=23
    var snowcolor=new Array("#009900")
    var snowtype=new Array("arial")
    var snowletter="<img id='fall' src='http://sharepoint2.bankofamerica.com/sites/aging_and_quality/Shared%20Documents/fall.png'</img>"
    var sinkspeed=0.6
    var snowmaxsize=35
    var snowminsize=21
    var snowingzone=1
    var snow=new Array()
    var marginbottom
    var marginright
    var timer
    var i_snow=0
    var x_mv=new Array();
    var crds=new Array();
    var lftrght=new Array();
    var browserinfos=navigator.userAgent
    var ie5=document.all&&document.getElementById&&!browserinfos.match(/Opera/)
    var ns6=document.getElementById&&!document.all
    var opera=browserinfos.match(/Opera/)
    var browserok=ie5||ns6||opera



    function randommaker(range) {
    rand=Math.floor(range*Math.random())
    return rand
    }

    function initsnow() {
    if (ie5 || opera) {
    marginbottom = document.body.clientHeight
    marginright = document.body.clientWidth
    }
    else if (ns6) {
    marginbottom = window.innerHeight
    marginright = window.innerWidth
    }
    var snowsizerange=snowmaxsize-snowminsize
    for (i=0;i<=snowmax;i++) {
    crds[i] = 0;
    lftrght[i] = Math.random()*15;
    x_mv[i] = 0.03 + Math.random()/10;
    snow[i]=document.getElementById("s"+i)
    snow[i].style.fontFamily=snowtype[randommaker(snowtype.length)]
    snow[i].size=randommaker(snowsizerange)+snowminsize
    snow[i].style.fontSize=snow[i].size
    snow[i].style.color=snowcolor[randommaker(snowcolor.length)]
    snow[i].sink=sinkspeed*snow[i].size/5
    if (snowingzone==1) {snow[i].posx=randommaker(marginright-snow[i].size)}
    if (snowingzone==2) {snow[i].posx=randommaker(marginright/2-snow[i].size)}
    if (snowingzone==3) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/4}
    if (snowingzone==4) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/2}
    snow[i].posy=randommaker(6*marginbottom-marginbottom-6*snow[i].size)
    snow[i].style.left=snow[i].posx
    snow[i].style.top=snow[i].posy
    }
    movesnow()
    }

    function movesnow() {
    for (i=0;i<=snowmax;i++) {
    crds[i] += x_mv[i];
    snow[i].posy+=snow[i].sink
    snow[i].style.left=snow[i].posx+lftrght[i]*Math.sin(crds[i]);
    snow[i].style.top=snow[i].posy

    if (snow[i].posy>=marginbottom+6*snow[i].size || parseInt(snow[i].style.left)>(marginright-3*lftrght[i])){
    if (snowingzone==1) {snow[i].posx=randommaker(marginright-snow[i].size)}
    if (snowingzone==2) {snow[i].posx=randommaker(marginright/2-snow[i].size)}
    if (snowingzone==3) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/4}
    if (snowingzone==4) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/2}
    snow[i].posy=0
    }
    }
    var timer=setTimeout("movesnow()",50)
    }

    for (i=0;i<=snowmax;i++) {
    document.write("<span id='s"+i+"' style='position:absolute;top:-"+snowmaxsize+"'>"+snowletter+"</span>")
    }
    if (browserok) {
    window.onload=initsnow
    }


    </script>

  2. #2
    Join Date
    Aug 2012
    Posts
    43
    try jquery.
    maybe http://api.jquery.com/detach/ can help.
    you will need to refer to the image and then detach it? (detaching because then its not totally removed from the dom)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles