logo

NJP

Collapse Navigation and Header Frames via Script

Import · Nov 06, 2012 · article

Home/System UI/UI scripts/Collapse Navigation and Header Frames via Script

E

very once in a while I come across some script functions that might be useful given the right requirement. This article is one of those cases. In the post below I’ll show you how you can leverage some built-in client-side functions to show and hide the navigation and header frames in ServiceNow.

Navigation/Banner Frames

Navigation Frame

The navigation frame can be hidden, shown, or toggled using the following functions…

//Hide the left nav

hideNav();

//Show the left nav

showNav();

//Toggle the left nav

toggleNav();

Here’s an example global UI script that you could use to hide the left nav from end-users

‘HideLeftNav’ UI Script

Name: ‘HideLeftNav’

Global: true

Description: Hide the left nav for end users

Script:

addLoadEvent(hideLeftNav);

function hideLeftNav(){

try{

//If the user has no roles

if(!g_user.hasRoles()){

//Hide the left nav

hideNav();

//Hide the toggle image (optional)

//$('navToggleImage').hide();

}

}catch(e){}

}

Header/Banner Frame

The banner doesn’t have as many functions available to it, but you can still toggle the banner like this…

//Toggle the header/banner

toggleBanner();

View original source

https://web.archive.org/web/20210117183344/https://servicenowguru.com/system-ui/ui-scripts-system-ui/collapse-navigation-header-frames-script/