I am editing a SharePoint site for my company and am stuck. I'm using the Seattle layout and they would like the tree view on the side to be able to EXPAND/COLLAPSE. I've looked up a bunch of codes and tried to incorporate them but I'm clearly doing something wrong. I tried to do it through SP Designer but have no experience with that. Everything I find seems to be for older SP versions or something other than HTML which I don't know how to incorporate properly. This is the latest code I found, but just realized the source said its specific to SP 2007. Is there a way to edit this code to make it work for 2013, or does anyone else know how to make the side bar expand/collapse? Thanks so much.


<script type="text/javascript">

function WPToggle(thisId, ImageId)
if (document.getElementById(thisId).style.display=="none")
document.getElementById(ImageId).src = "/_layouts/images/minus.gif";
document.getElementById(ImageId).src = "/_layouts/images/plus.gif";

function ExpandCollapseBody()
var i = 1;
var WPid = "WebPartWPQ1" ;
var WPtitleid = "WebPartTitleWPQ1" ;
var Toggleid = "ToggleImage1" ;
document.getElementById(WPtitleid).innerHTML = '<IMG id="' + Toggleid + '" onClick="WPToggle(\'' + WPid + '\',\'' + Toggleid + '\')" alt="Expand/Collapse" style="margin:6px 5px 0px 2px; float:left; cursor:pointer;" src="/_layouts/images/minus.gif" />' + document.getElementById(WPtitleid).innerHTML ;
if (document.getElementById(WPid).style.display=="none")
document.getElementById(Toggleid).src = "/_layouts/images/plus.gif";
catch(err) {}
i = i + 1;
WPid = "WebPartWPQ" + i ;
WPtitleid = "WebPartTitleWPQ" + i;
Toggleid = "ToggleImage" + i;
} while (document.getElementById(WPid))


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.