Collapse Navigation and Header Frames via Script

Every 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();

Date Posted:

November 6, 2012

Share This:

2 Comments

  1. Mark Landis November 15, 2012 at 1:48 pm

    Would there be a way to hide the bottom frame via script? I’ve had several individuals who somehow activated the bottom frame without realizing, but did not drag it out to make its contents visible.

    This caused links clicked in lists/nav windows to load in the hidden frame.

    Thanks in advance!

  2. Priya October 25, 2013 at 4:45 pm

    Hi Mark,

    These functions doesn’t work as expected in ServiceNow New UI. Is there any other method which can be used to hide header and navigator for ServiceNow new UI?

    Thanks

Comments are closed.

Categories

Tags

Loading

Fresh Content
Direct to Your Inbox

Just add your email and hit subscribe to stay informed.