Results 1 to 2 of 2

Thread: Daily iframe content script

  1. #1
    Join Date
    May 2006
    Posts
    266
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Daily iframe content script

    Hi i need some help.
    i found a code i would like to use however i would like to put my time zone in the script +gmt 8

    would lany one know how here is the script


    Head

    <script language="JavaScript1.2">

    //Daily iframe content- © Dynamic Drive (www.dynamicdrive.com)
    //For full source code, and Terms Of use, visit http://dynamicdrive.com
    //This credit MUST stay intact for use

    var ie=document.all&&navigator.userAgent.indexOf("Opera")==-1
    var dom=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1

    //Specify IFRAME display attributes
    var iframeprops='width=150 height=150 marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="1" scrolling="no"'

    //Specify 7 URLs to display inside iframe, one for each day of week
    var daycontent=new Array()
    daycontent[1]="monday.htm" //Monday content
    daycontent[2]="tuesday.htm" //Tuesday content
    daycontent[3]="wednesday.htm"
    daycontent[4]="thursday.htm"
    daycontent[5]="friday.htm"
    daycontent[6]="saturday.htm"
    daycontent[0]="sunday.htm"

    //No need to edit after here
    if (ie||dom)
    document.write('<iframe id="dynstuff" src="" '+iframeprops+'></iframe>')

    var mydate=new Date()
    var mytoday=mydate.getDay()

    function dayofweek_iframe(){
    if (ie||dom){
    var iframeobj=document.getElementById? document.getElementById("dynstuff") : document.all.dynstuff
    iframeobj.src=daycontent[mytoday]
    }
    }

    window.onload=dayofweek_iframe

    </script>
    Body
    <script type="text/javascript">

    //ID of Daily Iframe tag:
    var iframeids=["dynstuff"]

    var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
    var FFextraHeight=getFFVersion>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

    function startdyncode(){
    dyniframesize()
    }

    function dyniframesize() {
    var dyniframe=new Array()
    for (i=0; i<iframeids.length; i++){
    if (document.getElementById){ //begin resizing iframe procedure
    dyniframe[dyniframe.length] = document.getElementById(iframeids[i]);
    if (dyniframe[i] && !window.opera){
    dyniframe[i].style.display="block"
    if (dyniframe[i].contentDocument && dyniframe[i].contentDocument.body.offsetHeight) //ns6 syntax
    dyniframe[i].height = dyniframe[i].contentDocument.body.offsetHeight+FFextraHeight;
    else if (dyniframe[i].Document && dyniframe[i].Document.body.scrollHeight) //ie5+ syntax
    dyniframe[i].height = dyniframe[i].Document.body.scrollHeight;
    }
    }
    }
    }

    if (window.addEventListener)
    window.addEventListener("load", startdyncode, false)
    else if (window.attachEvent)
    window.attachEvent("onload", startdyncode)

    </script>
    Thanks Please help

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

    Default

    Ok, to get the date to return the current day (monday, tuesday etc) based on GMT+8 time, try modifying the line:

    Code:
    var mydate=new Date()
    inside the script to:

    Code:
    var mydate=new Date()
    mydate.setHours(mydate.getHours()+mydate.getTimezoneOffset()/60+8) //GMT+8

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
  •