Tuesday, September 27, 2011

window.onload being used in multiple places within the same application included

Recently one of my team members ran into an issue where we had used
the window.onload to dynamically set some values in a cookie object.
Our application handles multiple javascript files and we had used
window.onload in another jsp also for another reason.

So,when multiple jsp files are trying to add different functions to the window.onload event, only the last function was executing. We developed a workaround by adding the function that chains the onload event functions. Below snippet gives an example of how we solved it.

-
function addLoadEvent(functionName) {
var firstonload = window.onload;

if (typeof window.onload != 'function') {
window.onload =
functionName;
}
else {
window.onload = function() {
if (
firstonload ) {
firstonload();
}
functionName();
}
}
}


and the actual function definition is in the original jsp and this
function is called from there. So the first time window.onload may
not be a function so we are setting it, On subsequent assignments,
window.onload exists, so whatever it holds will be wrapped up with the
new function. the list grows like that...

8 comments:

Tom said...

It is very nice BTW! But If you really want to write something good, you can ask this guys for help! They really know how to write essay and will help you with homework! Just write to them thesis help and be happy about it! Enjoy!

Ariel Wilson said...

I almost facing a similar issue yesterday when I'm working on my dissertation posters projects, I try a lot of things and nothing worked for me, but finally, I got a perfect solution.

Goldyy said...

You can never go wrong when you order assignments from our reliable service. Our experts work fast and deliver top-notch content essayswriting org reviews. Don’t hesitate! Order papers at professional custom essay writing service and enhance your college performance.

bojo2112jon said...

Good day! That is not the same info what I am looking for, but at least something. After 3 years of working online there is not much information about any interesting top and new future powerful computer technologies. I was on the edge of trying luck with one online company checked reviews. And now I'm working at writing agency, that I could not even imagine. So, friends, click on this https://www.nursingpaper.com/our-services/nursing-essay-writing-service/ website and order your assignments online!

Whome1996 said...

I love to walk and therefore I prefer to spend time to my taste, and most students like this site https://essaysrescue.com/slader-review/, which helps in writing papers for every taste and color, experts will write the best paper, you will be delighted

Tommy543 said...

You can hire a qualified human editor to perfect your work. A do my essay seasoned professional who can polish your paper, get rid of mistakes, fix logical inconsistencies, and improve the overall quality of the text. The final result is a sure A+.

Rhys Alexander said...

When you purchase assignments from our dissertation writing service, you can never go wrong. digital marketing dissertation
 Our professionals work quickly and produce excellent articles. Be quick to act! Enhance your college success by placing an order for papers from a reputable digial marketing dissertation writing service.

donaldriskell said...

Every parent wants to provide their child the best chance of success in the future and to support their educational growth during their early years. I’m pretty sure that you agree with this. Anyway, that is not the reason why I’m here. I’m here because I want to share this game Dragonscapes Adventure with you. I notice that you’re searching for a game that you can play for free and that’s it. You can also visit the link I drop below for additional games.

LINK DOWNLOAD Stumble Guys - PC