Friday, March 1, 2019

The way to remove the UniversalHeader frame from the peoplesoft through javascript (Top Navigation Bar of Peoplecode)

So after searching for a solution to this for the past four to five days I gave up all hope and tried to think the way of the real developer and a hacker of course. The motive behind removing the god damn navigation header which contains the Home , Add Favourites and Sign out hrefs was simple, to trap the user to fill a form before proceeding the the main home page. I have been a developing pages on peoplesoft for the past two years and this was the first major obstacle I had to face for a very long time. Dont get me wrong I am an innovator and like to stretch the limits of any framework I am given. As this task had a time line on it, it was both fun and tense at the same time. Ok enough of the talk lets start with what my approach was. So I have added Iscripts before and I have dabbled in the signon peoplecode area too, so I know that you can easily show a page before the homepage without any problem. The main issue this time was that I needed to upload stuff and make a button which could call a report, that as we all know can only be done in peoplecode. So i mixed it up a bit. I redirected my user to a native peoplesoft page on the signon peoplecode function (custom made weblib record).  Now the problem was I needed to force the user to enter a survey and then proceed but the navigation bar was visible. So this is what I came up with. In the native peoplesoft page I added an html. and i wrote the below code in the html:


<script language='javascript'>
window.onload = function()
{
var test1 = top.window.frames['UniversalHeader'];
var pageToDestory = test1.document.getElementsByClassName('PSPAGE')[0];
pageToDestory.style.display ="none";
}

</script>




A simple and effective strike. Now what the problem peoplesoft makes two frames one frame is the UniversalHeader which is on the top of the page where ever we go and the second one is the frame which contains your page. No crumbs = true (xD) . the html which is custom made by the developer resides in the second frame. This code although resides in the second frame, it jumps to the first frame through.
var test1 = top.window.frames['UniversalHeader'];
    Now we have access to the first frame elements. Next is to get the page in the first frame which contains the navigation bar.
var pageToDestory = test1.document.getElementsByClassName('PSPAGE')[0];
  Then simply make display none.


Simple and elegent