Wed 31 Aug 2005
PeopleSoft Page – JavaScript Insertion
Posted by ChiliJoe under PeopleSoft • Tips & Techniques • PeopleTools • PIAOne way to customize a PeopleSoft page is to execute javascript to manipulate the DOM. Some possible scenarios that may make this necessary:
- add dynamic elements to your page (set some elements as draggable maybe? or perhaps adding mouseover behavior to PeopleSoft page elements)
- removal/manipulation of elements not accessible via Application Designer (automatically added elements outside of a page definition: navigation elements, Close/Ok/Apply buttons in modal pages, etc.)
In Application Designer, insert a HTML Area on the page definition. The HTML Area can be placed anywhere on the page, however the attached javascript should not directly perform the DOM manipulations. To ensure all of the objects you want to manipulate are already loaded, attach the code on the window.onload event handler. The onload event should not be directly overridden either, lest you override any function already assigned by the PeopleSoft page processor. The proper way of javascript insertion is to append to the onload event. The best way to do this is using this technique by Simon Willison.
The HTML Area should look like the following:
<script type="text/javascript">
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
}
}
}
addLoadEvent(function() {
/* code to run on page load */
});
</script>
July 13th, 2006 at 3:19 am
Ok, I gotta give you props on this.
Google + You + Frustrated Developer != Frustrated Developer
March 27th, 2007 at 4:34 pm
simply superb….
March 4th, 2008 at 2:11 am
Thanks for the post. I just used this code with some other work I’m doing.
Thanks again.
March 4th, 2008 at 2:13 am
btw I totally again with Kyle. Keep it the good work!
July 31st, 2008 at 1:46 pm
Can someone please Help me on this.
I have HTML Area below Long Edit Box. I have to count how many characters are being keyed in the Long Edit Box and display that in the HTML Area.
When User enter 254 Characters then I have to display a message.
What is the code I should?
Where should I write that code?
Your Help on this is really appreciated.
July 31st, 2008 at 5:01 pm
Where do I need to put the code in HTML Properties OR create new HTML Definition place the code and call that definition from PeopleCode.
Where Should I put the Functions in any of the Peoplecode event?
From Where should I make the function calls to JAVA Script. I am totally confused. Can somebody help on this