PDA

View Full Version : Monthly iFrame Content Script



gazza58
11-19-2015, 08:37 PM
Hello

Can anyone advise how I can modify the Daily iFrame Content Script

http://www.dynamicdrive.com/dynamicindex17/dowiframe2.htm

So it becomes a Monthly Content Script (i.e. displays a message for a calendar month)

Many Thanks

Beverleyh
11-19-2015, 09:11 PM
Change;
var mytoday=mydate.getDate()to
var mytoday=mydate.getMonth()
and start the page array from 0 (January is 0, December is 11)
daycontent[0]="january.htm"

gazza58
11-20-2015, 01:12 PM
Many Thanks, I'll give it a go

gazza58
11-20-2015, 01:20 PM
Sorry - another question, is it possible to add a Forward and Backwards button so a visitor could look forward a month or back a month

i.e. would something like

backButton.onclick = function() {
// do something
}

forwardButton.onclick = function() {
//do something else
}

Work

Thanks

gazza58
11-23-2015, 01:19 PM
Just looking on the internet if I were to add the following

iframe.contentWindow.history.go(-1); // back
iframe.contentWindow.history.go(1); // forward

Would this work for Buttons to take the Calendar Back or Forwards 1 month

What I'm looking to achieve is a list of events for the current month but allow the visitor to go forward to the next month ot back one month

any assistance appreciated

Beverleyh
11-23-2015, 04:39 PM
history.go ... Would this work for Buttons to take the Calendar Back or Forwards 1 monthNo because history.go() is looking for page history stored in the browser, so if the month either side hasn't been viewed already, it wont be in the history to navigate to.

A better approach would probably be to write a nextMonth() and prevMonth() function and then increment the numerical value of 'mytoday' when the appropriate button is clicked.

gazza58
11-25-2015, 09:24 AM
Hello

I have modified the script and placed the following in the page


<script type="text/javascript">

/***********************************************
* Daily iframe content II- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Please keep this notice intact
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var ie=document.all
var dom=document.getElementById

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

//Specify 31 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 monthcontent=new Array()
monthcontent[0]="January.html"
monthcontent[1]="February.html"
monthcontent[2]="March.html"
monthcontent[3]="April.html"
monthcontent[4]="May.html"
monthcontent[5]="June.html"
monthcontent[6]="July.html"
monthcontent[7]="August.html"
monthcontent[8]="September.html"
monthcontent[9]="October.html"
monthcontent[10]="November.html"
monthcontent[11]="December.html"

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

var mydate=new Date()
var mytoday=mydate.getMonth()

function dayofmonth_iframe(){
if (ie||dom){
var iframeobj=document.getElementById? document.getElementById("dynstuff") : document.all.dynstuff
iframeobj.src=monthcontent[mytoday]
}
}

window.onload=dayofmonth_iframe

</script>

I have created the files for the months, the Window appears but with no content

Beverleyh
11-25-2015, 12:43 PM
The code you posted works fine here. Have you checked the file names for correct path and case-sensitivity? File extension correct?

Beverleyh
11-25-2015, 07:15 PM
An updated script http://fofwebdesign.co.uk/template/_testing/frames/monthly/

gazza58
11-26-2015, 08:27 AM
Many thanks