My JavaScript book is out! Don't miss the opportunity to upgrade your beginner or average dev skills.

Wednesday, April 09, 2008

S.O.S. JavaScript - How to recover your stuff !!!

In this Ajax Web era there are a lot of sites that use JavaScript to perform simple or complex stuff.

Sometime, one of these site could be "not so well" programmed, specially during client-server interactions.

For example, it happens few days ago that while I was trying to post a message to another "friend", an error occurred during this operation.

The result was a beautiful fake popup with returned server error information and only a button to close them ... and I wondered what about my content? Can I try again to send them?

The answer was NO, because the SEND button has been disabled, and the worst thing is that the textarea with my message was disabled as well.

I wasn't able to get my message content again because of some client/server error and some bad logic in the client side. What could we do in these cases?

Reading the source? ... uhm, content wasn't there ...
Using firebug? Maybe, but content could not be there as well ...

Press F5 and reload the page? ... ok, but why should we loose our content in this way? What I mean, I wasted my time to write that message and why on heart should I spend twice ... ok, ok, here I come with these "stupid" links:

If you bookmark these links, dragging them in your Browser Bookmarks area, you will be able in 90% of cases to enable again the blocked page.

Basically, I created the first one (runtime and in few seconds), Enable Area, to get my content that was inside the disabled textarea, to refresh the page and try the entire operation without loosing whatever I wrote before.

The simple used code is this one:


and the difference between those links is only in the sent parameter, the first is the string textarea, the second is the string input, and finally the third one is the string button.

These links, and this code, are compatible with every browser that supports javascript uris (so, basically, every recent browser where recent means since some year ago ...)

Finally, in this way we use JavaScript to help us with pages that have problems with JavaScript, sounds weird? :D


CTAPbIu_MABP said...
This comment has been removed by the author.
Andrea Giammarchi said...

because the initial purpose was to get my content again, not to enable everything :D

Anyway, two vars are used exactly to avoid var (so that's the smallest script I could think about).

You missed some bracket in your code and it will simply fail.

Try this one ;)

(function(S,o,s){for(s in S){

CTAPbIu_MABP said...
This comment has been removed by the author.
Andrea Giammarchi said...

done, Cheers :)