By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,934 Members | 1,441 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,934 IT Pros & Developers. It's quick & easy.

Assigning document.writeln to object

P: n/a
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>test</title>
</head>
<body>
<script type="text/javascript">
try{
var foo=document.writeln;
foo( 'Hello, world!' );
}
catch( e ) {
alert( e );
}
</script>
</body></html>

IE has no problem with this, but Firefox throws an exception -
"Illegal operation on WrappedNative prototype object". Is it within
its rights to do so?

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a


Christopher Benson-Manica wrote:

var foo=document.writeln;
foo( 'Hello, world!' ); IE has no problem with this, but Firefox throws an exception -
"Illegal operation on WrappedNative prototype object". Is it within
its rights to do so?


Depends on the legal system of the country you are using Firefox in :).
Seriously, writeln is a native method of the document object which if
assigned to a global variable is no longer bound to the document object
but the window object and calling writeln on the window doesn't make
much sense.
Why do you need that? Or what do you want to achieve, perhaps there are
other ways to do that.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2

P: n/a
Martin Honnen <ma*******@yahoo.de> spoke thus:
Depends on the legal system of the country you are using Firefox in :).
Seriously, writeln is a native method of the document object which if
assigned to a global variable is no longer bound to the document object
but the window object and calling writeln on the window doesn't make
much sense.
Oh! Well, that explains it...
Why do you need that? Or what do you want to achieve, perhaps there are
other ways to do that.


I don't, really - someone had suggested doing that in a previous post
here, but the difference was that it was at function scope and so this
issue wasn't relevant.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.