Static outlook calendar web page not performing properly in Sharepoint 2007

I have saved a copy of an outlook calendar as a web page to be displayed on my company's intranet. This calendar displays correctly when opened from within the documents library but does not work when displayed in the page viewer web part. The first month displays properly, but when clicking the arrow to advance to the next month I get an error (Page cannot be displayed). How do I get this calendar to advance through the months?
jrbell94Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

garignackCommented:
based upon what I saw in the code, the outlook static calendar uses a javascript functions called "NextMonth" and "PreviousMonth" to change the frames (header, month, details) to the next month.  This by default uses relative names (i.e. "2010m4h.html" instead of "http://site.mydomain.com/documentlib/2010m4h.html") it also expects that is is the top window, not nested in an iframe.  (note the top.frames[0].location)

This works fine from the document library because the relative urls still point to the correct location and it is the top frame.  when you do this from a webpart in a different page (i.e. http://site.mydomain.com/default.aspx) it likely tries pull up http://site.mydomain.com/2010m4h.html, which doesn't exist.  it also does this for the top frame, which will cause it to error the entire page with a page cannot be displayed.

The not so easy solution is to go into each of the static header pages (2010m3h.html, 2010m4h.html, 2010m5h.html etc.) and change the relative urls to full urls and the top.frames[n] lines to read parent.frames[n]
 (See code snippet )

I'm sure if you spent some time you could write a VBscript utility to do this for you, and run it immediately prior to uploading it to your document library.

From 2010m3h.html

function NextMonth(){
var strTemp;
var nextcalheader = '2010m4h.html';
var nextmonth = '2010m4.html';
var nextdetails = '2010d4.html';
nextcalheader = URLbase + nextcalheader;
nextmonth = URLbase + nextmonth;
nextdetails = URLbase + nextdetails;
top.frames[0].location = nextcalheader;
top.frames[3].location = nextmonth;
top.frames[4].location = nextdetails;
}

function NextMonthFixed(){
var strTemp;
var nextcalheader = 'http://site.mydomain.com/documentlib/2010m4h.html';
var nextmonth = 'http://site.mydomain.com/documentlib/2010m4.html';
var nextdetails = 'http://site.mydomain.com/documentlib/2010d4.html';
nextcalheader = URLbase + nextcalheader;
nextmonth = URLbase + nextmonth;
nextdetails = URLbase + nextdetails;
parent.frames[0].location = nextcalheader;
parent.frames[3].location = nextmonth;
parent.frames[4].location = nextdetails;
}

Open in new window

0
garignackCommented:
Update:

Looking a little bit closer at the entire file, it seems that you only need to change the following lines to look at the parent frame instead of the top frame.  

It generates the url base from the following lines:
var strTemp = new String(top.frames[0].location);
var curcalheader = '2010m3h.html';
var iCount = curcalheader.length;
var URLbase = strTemp.substring(0, strTemp.length - iCount);

and then applies them with these lines in the Nextmonth/PreviousMonth Functions:
nextcalheader = URLbase + nextcalheader;
nextmonth = URLbase + nextmonth;
nextdetails = URLbase + nextdetails;

so you would need to update the following:
var strTemp = new String(top.frames[0].location); -> var strTemp = new String(parent.frames[0].location);
top.frames[0].location = nextcalheader; -> parent.frames[0].location = nextcalheader;
top.frames[3].location = nextmonth; -> parent.frames[3].location = nextmonth;
top.frames[4].location = nextdetails; -> parent.frames[4].location = nextdetails;

I pasted the original html of the 2010m3h.html in the code attachment
<html><head><META HTTP-EQUIV='Content-Type' content='text/html; charset=utf-8'>
<title>Calendar</title>
<script language='JavaScript'>
if(top.IsMac && top.isIE && top.IEVersion < 4){
} else {
     document.write('<link rel=stylesheet href=cal.css type=text/css>');
}
</script>
<script language='JavaScript'>
var strTemp = new String(top.frames[0].location);
var curcalheader = '2010m3h.html';
var iCount = curcalheader.length;
var URLbase = strTemp.substring(0, strTemp.length - iCount);
function NextMonth(){
var strTemp;
var nextcalheader = '2010m4h.html';
var nextmonth = '2010m4.html';
var nextdetails = '2010d4.html';
nextcalheader = URLbase + nextcalheader;
nextmonth = URLbase + nextmonth;
nextdetails = URLbase + nextdetails;
top.frames[0].location = nextcalheader;
top.frames[3].location = nextmonth;
top.frames[4].location = nextdetails;
}
function PrevMonth(){
var prevcalheader = '';
var prevmonth = '';
var prevdetails = '';
prevcalheader = URLbase + prevcalheader;
prevmonth = URLbase + prevmonth;
prevdetails = URLbase + prevdetails;
top.frames[0].location = prevcalheader;
top.frames[3].location = prevmonth;
top.frames[4].location = prevdetails;
}
</script>
</head>
<body margin=0px bgcolor='#99CCCC'>
<table dir=ltr border=0 cellspacing=0 cellpadding=0 width=100% height=100% class=CalHeader><tr><td align=center colspan=2 class=CalTitle nowrap bgcolor='#669999'><font size=4>Garignack</font></td></tr><tr><td align=left colspan=2 valign=bottom>
<table cellpadding=0 cellspacing=0><tr><td align=left width=45px>&nbsp;</td><td align=left valign=bottom class=CalMonth><font size=4>March 2010</font></td><td align=right width=45px><a href='javascript:NextMonth();' style='cursor:hand;'><img src=MONTHR.GIF border=0></a></td></tr></table></td></tr></table></body></html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jrbell94Author Commented:
The solution was excellent for what I asked for and very much appreciated. What I did not ask was how to get the calendar to go back to the previous month. But following the solution guidlines I just adjusted each calendar page (ie. 2010m3h.html) as directed and I was able to go back to the previous calendar as well. Again, thanks for the help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Networking

From novice to tech pro — start learning today.