Results 1 to 5 of 5

Thread: Daily IFrame II Question

  1. #1
    Join Date
    Dec 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Daily IFrame II Question

    Script - Daily IFrame II
    http://www.dynamicdrive.com/dynamici...dowiframe2.htm

    I know that it says that this may be overlooked but I would really appreciate some help. I currently use this script and it is GREAT. The only challenge that I have is that there is a limit to the number of days. Is there a version of it somewhere that will scroll through daily without limiting the number of items to be scrolled through? Or is this something that can be easily changed?

    I'm basically looking for it to scroll through 50 items and then start over again.

    Thank you,
    Ashley
    Last edited by AshleyG; 12-30-2004 at 05:50 AM.

  2. #2
    Join Date
    Dec 2004
    Posts
    177
    Thanks
    0
    Thanked 18 Times in 17 Posts

    Default

    Well, the script is based on the days, and obviously there aren't more than 31 days in a month (that I know of ). The code could be edited to allow more items, but if you still want it daily, it will be a little bit harder. I'll see what I can do to help, though.

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

    Default

    Hi AshleyG:
    It's certainly possible, though once you go beyond the default 31 days (for 1 month), it's not longer "trivial" to get this to work. Unfortunately due to time constraint, I can only revisit this thread if I find the time.

  4. #4
    Join Date
    Dec 2004
    Posts
    177
    Thanks
    0
    Thanked 18 Times in 17 Posts

    Default

    Alrighty, here's what I have. This isn't 100% tested mind you, as I didn't have 50 sites nor the amount of time it would take to FULLY test it. But, on the tests that were run, it worked beautifully.

    Basically, instead of going by the day of the month, this uses the day of the year, essentially giving you a maximum of 365 different URLs you could use (366 on leap years, which, yes, it does check). And, it will loop itself continually, so after 50 items are done, it starts right back at number one.
    It will work for any amount of items, so if that may change, simply put that number in where marked ('var itemNum='). Just make sure you have AT LEAST that number of URLs as well. Hopes it works for ya, Cheers.
    -Minos

    Code:
    <script type="text/javascript">
    
    /***********************************************
    * Daily iframe content II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
    * Modified by Nick Faiola to allow +31 URLs
    ***********************************************/
    //Number of Items
    var itemNum=31
    
    var ie=document.all
    var dom=document.getElementById
    
    //Specify IFRAME display attributes
    var iframeprops='width=300 height=300 marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="1" scrolling="no"'
    
    //Specify 'itemNum' URLs to display inside iframe, one for each day of the current month
    //If this month has less than 31 days, the last few URLs won't be used.
    var content=new Array()
    content[1]=""
    content[2]=""
    content[3]=""
    content[4]=""
    content[5]=""
    content[6]=""
    content[7]=""
    content[8]=""
    content[9]=""
    content[10]=""
    content[11]=""
    content[12]=""
    content[13]=""
    content[14]=""
    content[15]=""
    content[16]=""
    content[17]=""
    content[18]=""
    content[19]=""
    content[20]=""
    content[21]=""
    content[22]=""
    content[23]=""
    content[24]=""
    content[25]=""
    content[26]=""
    content[27]=""
    content[28]=""
    content[29]=""
    content[30]=""
    content[31]=""
    
    //No need to edit after here
    var months=new Array(31,28,31,30,31,30,31,31,30,31,30,31)
    
    if (ie||dom) document.write('<iframe id="dynstuff" src="" '+iframeprops+'></iframe>')
    
    var mydate=new Date()
    var myMonth=mydate.getMonth()
    var myToday=mydate.getDate()
    var myYear=mydate.getYear()
    var dateOfYear=0
    
    function isLeapYear(year){
     if (year%4!=0) return false
     if (year%100==0){
      if (year%400==0) return true
      return false
     }
     return true
    }
    
    function dayOfYear(){
     for (i=0;i<myMonth;i++)
        dateOfYear+=months[i]
     dateOfYear+=myToday
     if (myYear<1000) myYear+=1900
     if (isLeapYear(myYear) && myMonth > 1) dateOfYear++
     dateOfYear=(dateOfYear%itemNum!=0)? dateOfYear%itemNum : itemNum
     return dateOfYear
    }
    
    
    function dayofmonth_iframe(){
     if (ie||dom){
      var iframeobj=document.getElementById? document.getElementById("dynstuff") : document.all.dynstuff
      iframeobj.src=content[dayOfYear()]
     }
    }
    
    window.onload=dayofmonth_iframe()
    </script>

  5. #5
    Join Date
    Dec 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Thank you!!

    Thank you, Minos! I appreciate your help. I will test it on my site and post to everyone if it works!

    Much gratitude,
    Ashley

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
  •