PDA

View Full Version : Daily IFrame II Question



AshleyG
12-30-2004, 05:45 AM
Script - Daily IFrame II
http://www.dynamicdrive.com/dynamicindex17/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

Minos
01-03-2005, 08:40 AM
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.

ddadmin
01-04-2005, 01:23 PM
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.

Minos
01-06-2005, 10:10 AM
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



<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>

AshleyG
01-09-2005, 03:00 AM
Thank you, Minos! I appreciate your help. I will test it on my site and post to everyone if it works!

Much gratitude,
Ashley