I want to hide ribbon form my newform.aspx & editform.aspx forms only. I don't want to hide ribbon from my whole site. I just want that whenever a user add or edit item top ribbon must be hidden from user
1 Answer
One possibility would be to add some javascript to your masterpage code's <head>
. This code checks your current location and if the location has newform.aspx
or editform.aspx
in it, it'll hide the ribbon.
<script type="text/javascript "src="http://mypath.com/Scripts/jquery.min.js</script>
<script type="text/javascript">
$( document ).ready(function() {
var pathname = window.location.pathname;
if (pathname.indexOf("newform.aspx") >= 0)
document.getElementById( 'RibbonContainer' ).style.display = 'none';
else if (pathname.indexOf("editform.aspx") >= 0)
document.getElementById( 'RibbonContainer' ).style.display = 'none';
});
</script>