Closed Bug 420201 Opened 16 years ago Closed 16 years ago

cannot hook "document.write"

Categories

(Firefox :: General, defect)

x86
Windows 98
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 252291

People

(Reporter: zero794, Unassigned)

Details

User-Agent:       Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)
Build Identifier: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1

The following code works ok with IE 5.5 (not tested on higher vers),
but doesn't in Mozilla 2.0.0.1:

var dw0 = document.write,
    r1 = /<script[\s>]/i,
    r2 = new RegExp("</script\\s*>", "i");
function dw(s)
{ if (!r1.test(s) || !r2.test(s))
    dw0(s);
  else
    dw0("Nested &lt;SCRIPT&gt;s");
}
document.write = dw;

Now all consequent "document.write(...)" calls will result in error.
Don't ask me why I need such functionality, it's not an idle issue;
somebody who's got enough brains can guess where I use it ...


Reproducible: Always

Steps to Reproduce:
1. inject the code above into an empty page
2. call "document.write('Hello, world!')"

Actual Results:  
Error: uncaught exception: [Exception... "Illegal operation on WrappedNative prototype object"  nsresult: "0x8057000c (NS_ERROR_XPC_BAD_OP_ON_WN_PROTO)"  location: "JS frame :: file:///C:/1/1.htm :: dw :: line 8"  data: no]


Expected Results:  
the message displayed

nothing
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.