Assigning document.writeln to object

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christopher Benson-Manica

    Assigning document.writeln to object

    <!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.wr iteln;
    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)cybers pace.org | don't, I need to know. Flames welcome.
  • Martin Honnen

    #2
    Re: Assigning document.writel n to object



    Christopher Benson-Manica wrote:

    [color=blue]
    > var foo=document.wr iteln;
    > foo( 'Hello, world!' );[/color]
    [color=blue]
    > 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?[/color]

    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

    Comment

    • Christopher Benson-Manica

      #3
      Re: Assigning document.writel n to object

      Martin Honnen <mahotrash@yaho o.de> spoke thus:
      [color=blue]
      > 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.[/color]

      Oh! Well, that explains it...
      [color=blue]
      > Why do you need that? Or what do you want to achieve, perhaps there are
      > other ways to do that.[/color]

      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)cybers pace.org | don't, I need to know. Flames welcome.

      Comment

      Working...