Results 1 to 3 of 3

Thread: Javascript Dilemma, Simple Solution.?

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

    Default Javascript Dilemma, Simple Solution.?

    Date & Time : Dynamic Countdown Script II
    http://www.dynamicdrive.com/dynamici...htmlcount2.htm

    My website will be a year old tonight @ midnight, i've found a script that will countdown till 12:00 pm, Nov 16th... Unfortunately, this script will only display a message box, i would like this script to redirect my page to a new location once the desired time has been reached '12:00 Pm, Nov 16th' any help would be wonderful.

    Code:
    <br><center><script language="JavaScript1.2">
    
    //Dynamic countdown Script II- © Dynamic Drive (www.dynamicdrive.com)
    //Support for hour minutes and seconds added by Chuck Winrich (winrich@babson.edu) on 12-12-2001
    //For full source code, 100's more DHTML scripts, visit http://www.dynamicdrive.com
    
    function setcountdown(theyear,themonth,theday,thehour,themin,thesec){
    yr=theyear;mo=themonth;da=theday;hr=thehour;min=themin;sec=thesec
    }
    
    //////////CONFIGURE THE COUNTDOWN SCRIPT HERE//////////////////
    
    hour(0=midnight,23=11pm), minutes, seconds:
    setcountdown(2005,11,16,0,00,00)
    
    var occasion="Extinction"
    var message_on_occasion="Surprise! : Happy Birthday"
    
    var countdownwidth='450px'
    var countdownheight='40px'
    var countdownbgcolor='black'
    var opentags='<font face="Abbadon" color="yellow"><large>'
    var closetags='</large></font>'
    
    //////////DO NOT EDIT PAST THIS LINE//////////////////
    
    var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
    var crosscount=''
    
    function start_countdown(){
    if (document.layers)
    document.countdownnsmain.visibility="show"
    else if (document.all||document.getElementById)
    crosscount=document.getElementById&&!document.all?document.getElementById("countdownie") : countdownie
    countdown()
    }
    
    if (document.all||document.getElementById)
    document.write('<span id="countdownie" style="width:'+countdownwidth+'; background-color:'+countdownbgcolor+'"></span>')
    
    window.onload=start_countdown
    
    
    function countdown(){
    var today=new Date()
    var todayy=today.getYear()
    if (todayy < 1000)
    todayy+=1900
    var todaym=today.getMonth()
    var todayd=today.getDate()
    var todayh=today.getHours()
    var todaymin=today.getMinutes()
    var todaysec=today.getSeconds()
    var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
    futurestring=montharray[mo-1]+" "+da+", "+yr+" "+hr+":"+min+":"+sec
    dd=Date.parse(futurestring)-Date.parse(todaystring)
    dday=Math.floor(dd/(60*60*1000*24)*1)
    dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
    dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
    dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
    //if on day of occasion
    if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=1&&todayd==da){
    if (document.layers){
    document.countdownnsmain.document.countdownnssub.document.write(opentags+message_on_occasion+closetags)
    document.countdownnsmain.document.countdownnssub.document.close()
    }
    else if (document.all||document.getElementById)
    crosscount.innerHTML=opentags+message_on_occasion+closetags
    return
    }
    //if passed day of occasion
    else if (dday<=-1){
    if (document.layers){
    document.countdownnsmain.document.countdownnssub.document.write(opentags+"Occasion already passed! "+closetags)
    document.countdownnsmain.document.countdownnssub.document.close()
    }
    else if (document.all||document.getElementById)
    crosscount.innerHTML=opentags+"Occasion already passed! "+closetags
    return
    }
    //else, if not yet
    else{
    if (document.layers){
    document.countdownnsmain.document.countdownnssub.document.write(opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left until "+occasion+closetags)
    document.countdownnsmain.document.countdownnssub.document.close()
    }
    else if (document.all||document.getElementById)
    crosscount.innerHTML=opentags+dday+ " day, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left until "+occasion+closetags
    }
    setTimeout("countdown()",1000)
    }
    </script>
    
    <ilayer id="countdownnsmain" width=&{countdownwidth}; height=&{countdownheight}; bgColor=&{countdownbgcolor}; visibility=hide><layer id="countdownnssub" width=&{countdownwidth}; height=&{countdownheight}; left=0 top=0></layer></ilayer><br></center>

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    <br><center><script type="text/javascript">
    
    //Dynamic countdown Script II- © Dynamic Drive (www.dynamicdrive.com)
    //Support for hour minutes and seconds added by Chuck Winrich (winrich@babson.edu) on 12-12-2001
    //For full source code, 100's more DHTML scripts, visit http://www.dynamicdrive.com
    
    function setcountdown(theyear,themonth,theday,thehour,themin,thesec){
    yr=theyear;mo=themonth;da=theday;hr=thehour;min=themin;sec=thesec
    }
    
    //////////CONFIGURE THE COUNTDOWN SCRIPT HERE//////////////////
    
    hour(0=midnight,23=11pm), minutes, seconds:
    setcountdown(2005,11,16,0,00,00)
    
    var occasion="Extinction"
    var message_on_occasion="Surprise! : Happy Birthday"
    
    var countdownwidth='450px'
    var countdownheight='40px'
    var countdownbgcolor='black'
    var opentags='<font face="Abbadon" color="yellow"><large>'
    var closetags='</large></font>'
    
    //////////DO NOT EDIT PAST THIS LINE//////////////////
    
    var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
    var crosscount=''
    
    function start_countdown(){
    if (document.layers)
    document.countdownnsmain.visibility="show"
    else if (document.all||document.getElementById)
    crosscount=document.getElementById&&!document.all?document.getElementById("countdownie") : countdownie
    countdown()
    }
    
    if (document.all||document.getElementById)
    document.write('<span id="countdownie" style="width:'+countdownwidth+'; background-color:'+countdownbgcolor+'"></span>')
    
    window.onload=start_countdown
    
    
    function countdown(){
    var today=new Date()
    var todayy=today.getYear()
    if (todayy < 1000)
    todayy+=1900
    var todaym=today.getMonth()
    var todayd=today.getDate()
    var todayh=today.getHours()
    var todaymin=today.getMinutes()
    var todaysec=today.getSeconds()
    var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
    futurestring=montharray[mo-1]+" "+da+", "+yr+" "+hr+":"+min+":"+sec
    dd=Date.parse(futurestring)-Date.parse(todaystring)
    dday=Math.floor(dd/(60*60*1000*24)*1)
    dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
    dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
    dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
    //if on day of occasion
    if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=1&&todayd==da){
    window.location.href = "mypage.htm";
    return
    }
    //if passed day of occasion
    else if (dday<=-1){
    if (document.layers){
    document.countdownnsmain.document.countdownnssub.document.write(opentags+"Occasion already passed! "+closetags)
    document.countdownnsmain.document.countdownnssub.document.close()
    }
    else if (document.all||document.getElementById)
    crosscount.innerHTML=opentags+"Occasion already passed! "+closetags
    return
    }
    //else, if not yet
    else{
    if (document.layers){
    document.countdownnsmain.document.countdownnssub.document.write(opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left until "+occasion+closetags)
    document.countdownnsmain.document.countdownnssub.document.close()
    }
    else if (document.all||document.getElementById)
    crosscount.innerHTML=opentags+dday+ " day, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left until "+occasion+closetags
    }
    setTimeout("countdown()",1000)
    }
    </script>
    
    <ilayer id="countdownnsmain" width=&{countdownwidth}; height=&{countdownheight}; bgColor=&{countdownbgcolor}; visibility=hide><layer id="countdownnssub" width=&{countdownwidth}; height=&{countdownheight}; left=0 top=0></layer></ilayer><br></center>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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

    Default

    thank you... o.0

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
  •