PDA

View Full Version : Daily iframe content time setting



gralmy
03-10-2011, 12:00 AM
1) Script Title: daily iframe content

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/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

ddadmin
03-10-2011, 11:26 PM
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:


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


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

krististevens
05-31-2011, 11:44 PM
Is there a way to have this script make the iframe change more than once a day?

kennys
06-02-2011, 02:31 PM
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?