Post Reply 
Re-defining read-only JS methods
Jan. 03, 2009, 05:05 PM
Post: #1
Re-defining read-only JS methods
I'd like to accomplish below two changes in scripts:

Code:
Arbitrary_Object.userAgent
should become something equivalent to...
Code:
(Arbitrary_Object.PRXuserAgent || Arbitrary_Object.userAgent)


Code:
Arbitrary_Object.send(someArg)
should become something equivalent to...
Code:
if (Arbitrary_Object.setRequestHeader) Arbitrary_Object.setRequestHeader("X-Requested-With", "XMLHttpRequest");
Arbitrary_Object.send(someArg)

Probably the match has to be ".userAgent" and ".send \(", respectively, and the replacement shouldn't use quotes.

Any ideas?
Add Thank You Quote this message in a reply
Jan. 03, 2009, 05:58 PM
Post: #2
RE: Re-defining read-only JS methods
Not sure if you are looking for a filter or for a javascript. I know we can override/redefine functions, don't know how to do it, but maybe it would be the safest way...

How to redefine javascript native functions
Add Thank You Quote this message in a reply
Jan. 03, 2009, 06:18 PM
Post: #3
RE: Re-defining read-only JS methods
(Jan. 03, 2009 05:58 PM)lnminente Wrote:  Not sure if you are looking for a filter or for a javascript.

Whatever works. Smile!


The thing with above two cases is that "userAgent" is a read-only (no override whatsoever) property of "Navigator" (which may come with a different object name), and that "send" is a method of the XMLHttpRequest object which is entirely different in IE6 and W3C browsers.
Add Thank You Quote this message in a reply
Jan. 03, 2009, 08:06 PM
Post: #4
RE: Re-defining read-only JS methods
This could help someone: http://www.w3schools.com/htmldom/dom_obj_navigator.asp
Add Thank You Quote this message in a reply
Post Reply 


Forum Jump: