Removing Sharepoint Top and Left Navigation Using URL Query String Parameter

by Vishal 22. July 2011 11:52

Sometimes you may need to be able to display a page in MOSS with the left nav and top nav that is part of the default master page and layout. One of the reasons could be that you're trying to display the page within the frame of another application and only wish to show the page content.

In such a case here's a nifty way to hide the sharepoint 2007 navigational elements on a page without having to touch the masterpage or page layouts.

I crafted a custom webpart (attached) - dwp webpart without any server side code - that you can add to the webpart gallery of your site collection. The webpart is just a modified content editor webpart exported that puts a small ammount of javascript on the page to hide the navigation panes. It looks for a query string parameter called pure which if set to 1 will not display the navigation.

e.g. if the webpart is added to /default.aspx page on a site - if /default.aspx is called, the page will display as normal. If /default.aspx?pure=1 is called, the page will be displayed without any top nav or left nav.

ofcourse you can modify the script within the webpart any which way to only hide the left nav or only hide the top nav or hide custom elements as well with additional URL parameters.

this is the script that gets added to your page:

displaytype = JSRequest.QueryString["pure"];
document.write("<style>.ms-leftareacell,.ms-globallinks,.ms-siteaction,.ms-areaseparatorleft,.ms-rightareacell,.ms-areaseparatorright,.ms-areaseparatorcorner,.ms-titlearealeft,.ms-titlearearight,.ms-searchform,.ms-banner,.ms-buttonheightwidth,.ms-buttonheightwidth2, .ms-globalTitleArea, .ms-globalbreadcrumb, .ms-bannerContainer, .ms-pagetitleareaframe, .ms-consolestatuscell, .ms-pagemargin, .ms-bodyareapagemargin, .ms-pagebottommarginleft,.ms-pagebottommarginright, .ms-pagebottommargin, .ms-titleareaframe {display:none !IMPORTANT; } .ms-bodyareaframe, .ms-bodyareacell, .ms-propertysheet { border:0px !IMPORTANT; }</style>");

Quite simple really but effective. Enjoy.

NavigationHider.dwp (2.16 kb)


Comments (3) -

Chetana India
9/8/2011 8:06:03 PM #

Hi.. I have put the Javascript code in Content editor part but it is not working.. Canu tell me wats going wrong in it???

admin United States
9/12/2011 7:49:32 PM #

Chetana, You may be using a masterpage that is customized. You may have to change the element ids to conform to your page. unfortunately I cant see your page or the webpart that you put together so cannot say for sure why it would not be working. Have you tried installing the webpart as is instead of copying the code into a content editor part?

Jimmy Ly
Jimmy Ly Australia
8/12/2013 1:37:50 AM #

I must say i spent hours finding a way to hide global nagivation on share point sites, but this was the easiest and simplest way. It has alot of customisation.

If you want to hide items from your global links, simply go to your master page and look for all the classes you wish to hide, and then add it in the list.

You can even customise the string and number, and even have multiple display types!

Add comment

  Country flag
  • Comment
  • Preview

Repliques Montres haute qualite vous aider a economiser beaucoup tout en appreciant la valeur du nom de marque. Vous voulez avoir cette montre luxe haut de gamme suisses sur votre main, mais replica uhren l'achat d'une voiture semble une meilleure option. Oui, c'est la realite. Ces montres symbole de statut social co?tent quelque chose replicas de relojes qui est au-dela pour permettre pour une personne normale. Mais ne desesperez hublot replique montres pas si vous ne pouvez pas vous permettre d'acheter ces montres de luxe. Vous avez une belle occasion d'acheter des montres de prestige nom Replique de la marque. Certaines personnes aiment l'aspect d'un veritable montres au poignet, ou replique rolex montres voulez juste nombreuses montres de marque pour correspondre a leur habillement, mais evitez patek philippe replica orologi de depenser des milliers de dollars que une vraie montre mai cots, ils se tournent vers les replique montre montres bonne replique. Si vous ne voulez pas acheter des montres de veritables montres de haute qualite puis de replicas sont votre choix ideal.