Results 1 to 4 of 4

Thread: Daily iframe content time setting

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

    Default Daily iframe content time setting

    1) Script Title: daily iframe content

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici.../dowiframe.htm

    3) Describe problem: I would like this to change the content at a certain time of day...any ideas?

    also, where do I put the script for auto height? the page I'm using it on is www.btownbarscene.com and I had to enable scrolling to get the height right. the height of the frame will change daily so I would like it to be auto height.

    thanks.

    greg

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

    Default

    By default the content changes midnight of each day. If you wish the cut off point to be something different (ie: 3pm of each day), try adding the code in red to the script:

    Code:
    <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()
    var todaycontent=(mydate.getHours()>=15)? mytoday : mytoday-1
    todaycontent=(todaycontent<0)? 6 : todaycontent
    
    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>
    Where 15 in this case translates to 3pm (24 hour system) every day, so Sunday 2am would still show Saturday's content.

    also, where do I put the script for auto height?
    The auto resize add-on script would go at the bottom of your page:

    Code:
    <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>
    DD Admin

  3. #3
    Join Date
    May 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Is there a way to have this script make the iframe change more than once a day?

  4. #4
    Join Date
    Jun 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i can not get the certain time of day change to work, i need it to change over each day to the next day at 7am instead of midnight can someone please help?

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
  •