PDA

View Full Version : Weekly Iframe Content Script



gazza58
05-06-2014, 01:08 PM
Hello

I'm looking for a script similar to theDaily Iframe Content script but that displays different content on a weekly basis

I'm setting up a small website for a local sports league and want to display the fixtures for the forthcoming week. At the end of the season I just want to displat something like End of Season.

Could anyone assist or point me in the direction of a script that could create this

Many Thanks

jscheuer1
05-06-2014, 03:10 PM
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

</head>
<body>
<script type="text/javascript">

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

Date.prototype.getWeek = function() {
var onejan = new Date(this.getFullYear(),0,1);
return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);
};

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

//Specify up to 53 (0 to 52) URLs to display inside iframe, up to one for each week of the year, less than 53 will be reused starting at 0
// when they run out, the 53rd will only appear in years where there is a partial week left over at the end of the year (most years I think)
var weekcontent=[];
weekcontent[0]="0week.htm"
weekcontent[1]="1week.htm"
weekcontent[2]="2week.htm"
weekcontent[3]="3week.htm"
weekcontent[4]="4week.htm"
weekcontent[5]="5week.htm"
weekcontent[6]="6week.htm"

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

var mydate=new Date()
var thisweek=(mydate.getWeek() - 1) % weekcontent.length;

function dayofweek_iframe(){
var iframeobj=document.getElementById? document.getElementById("dynstuff") : document.all.dynstuff
iframeobj.src=weekcontent[thisweek]
}

window.onload=dayofweek_iframe

</script>
</body>
</html>

gazza58
05-06-2014, 06:28 PM
Many thanks,

I presume weeklycontent[0] is week 1 and it then works forward

Will give it a try but it appears that it will fit my requirement

jscheuer1
05-07-2014, 02:08 AM
That's right. How many different pages are you going to have? If you have 53, and they're numerically named in order, you won't have to list them in the code. If you're interested in that, let me know.

gazza58
05-10-2014, 07:19 AM
Many thanks for your help, all works well, just changed today