Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I found a very simple snippet that I can add to a CEWP that changes the view in a calendar web part from Day, Week and Month. This is for an external facing SharePoint site and the ribbon will not be available.

<div style="float:right">
<div style="float:left; padding-right:10px;">
 <a onclick="javascript:MoveView(&#39;day&#39;);" href="#">Day View</a> 
<div style="float:left; padding-right:10px;">
 <a onclick="javascript:MoveView(&#39;week&#39;);" href="#">Week View</a> 
<div style="float:left; padding-right:10px;">
 <a onclick="javascript:MoveView(&#39;month&#39;);" href="#">Month View</a> 

This works great until I add more calendars on my page. My snippet only works for the first calendar that was added and not the other calendar web parts.

After some searching, I figured out how to reference the specific calendar web part I wanted to change by using .getElementById using javascript. I tested by using the following funtion to hide the web part, this ensured that I was able to reference a specific web part.

<script language='javascript' type='text/javascript'> 
function myFunction()

<input type="button" onclick="myFunction()" value="Show alert box" />

Again this worked just fine, however I am at a loss on how to combine the two to make everything work together.

I plan to use two or maybe more different calendar web parts, each with it's own CEWP above it that will contain the javascript to change the view.

Any help will be greatly appreciated.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

This question was answered HERE.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.