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 want to make a few "special" pages in Sharepoint 2010, that hides the menu and ribbon from the Masterpage.

Is it possible to write JQuery code in a web part that can hide/disable/delete some masterpage elements?

Anyone have some tips or resources to how to achieve that?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Sure you can, almost all of the elements from the masterpages has an id and / or multiple classes that can help you identify them with jQuery.

Use the Content Editor WebPart and add your scripts in the HTML window of the webpart.

To identify the ID:s for specific elements in the DOM I recommend you to just inspect the page with the developer tools in your browser (e.g just hit F12 in IE or Chrome)

Then you could just select them with jQuery and hide them like:

jQuery("#s4-workspace").hide(); 

but using a correct ID or Class for the element you want to hide.

Just make sure that your functions are not executed until the DOM ir ready by attaching it to the jQuery.onload like this:

jQuery(YourFunctionName);

or without creating the function separetely:

jQuery(function(){
    jQuery("#s4-workspace").hide();
});
share|improve this answer

write javascript on page or place content editor webpart on page and linkup with your js

<script src="jquery file path" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function()
{
// do whatever operations with any element
    $('#s4-workspace').hide();
    $('#s4-workspace').show();
    $('#s4-ribbonrow').remove();        
    $('#s4-titlerow').css('display','none');
    $('#s4-workspace').css('display','block');
});
</script>
share|improve this answer

Your Answer

 
discard

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.