tags:

views:

532

answers:

4

Hi,

Mending a bug in our SAP BW web application, I need to call two javascript functions from the web framework library upon page load. The problem is that each of these functions reloads the page as a side-effect. In addition, I don't have access to modify these functions.

Any great ideas on how to execute a piece of code on "real" page load, then another piece of code on the subsequent load caused by this function, and then execute no code the third reload?

My best idea so far it to set a cookie on each go to determine what to run. I don't greatly love this solution. Anything better would be very welcome. And by the way, I do realize loading a page three times is absolutely ridiculous, but that's how we roll with SAP.

+2  A: 

A cookie would work just fine. Or you could modify the query string each time with a "mode=x" or "load=x" parameter.

This would present a problem if the user tries to bookmark the final page, though. If that's an option, the cookie solution is fine. I would guess they need cookies enabled to get that far in the app anyway?

Michael Haren
I agree use a cookie. We're only talking about volatile cookies which are are rarely turned off since many sites don't work well with them turned off and that is especially true of intranet solutions.
AnthonyWJones
+1  A: 

A cookie, or pass a query string parameter indicating which javascript function has been run. We had to do something along these lines to trip out a piece of our software. That's really the best I got.

Wes P
A: 

Use a cookie or set a hidden field value. My vote would be for the field value.

Chuck
A: 

This might be a cute case for using window.name, 'the property that survives page reloads'.

Marijn