Restoring window.event in IE

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sdt76
    New Member
    • Feb 2008
    • 3

    Restoring window.event in IE

    Hi everybody!

    I have a question regarding IE. I have a client using a script (which I can not change as it is an affiliate program's script that I can not control) that creates a variable called "event" and assigns a number to it. This is the line:

    Code:
    var event=7348734;
    Later on, there is another script that should use window.event, but... it does not work, because window.event gets rewritten by the previous script and it stays filled by the number!!!

    In your opinion, is there a way to empty the "event" variable, and restore it to its original state, including srcElement?
    I have tried setting:
    Code:
    event = null;
    event = window.event
    This resulted in having window.event value back to null, and its type as object (as it should be). But srcElement will not work :-(

    Any suggestions? Thanks in advance!
    Simone
  • mrhoo
    Contributor
    • Jun 2006
    • 428

    #2
    null always returns 'object' from typeof, because it is not 'undefined'.

    IE doesn't give you access to a constructor or prototype for event.

    I never thought of trying to assign event to something,
    but I gave it a whirl in IE7:
    window.event=33
    and got a 'member not found' error- but event was untouched.
    I don't have any old IE's around, so I don't know what they may do.

    Comment

    • sdt76
      New Member
      • Feb 2008
      • 3

      #3
      Originally posted by mrhoo
      I can't imagine the purpose of the 'affiliate' script, unless it is to discourage event handling in IE.
      unfortunately not... it is just a variable they arbitrarily called "event" without thinking about it :-(

      I'll make some tests... thanks anyway!

      cheers
      s

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Interesting. I don't know why it's not made read-only. This affects IE7 too.

        Is there no possibility of changing the script?

        Comment

        • sdt76
          New Member
          • Feb 2008
          • 3

          #5
          Originally posted by acoder
          Interesting. I don't know why it's not made read-only. This affects IE7 too.

          Is there no possibility of changing the script?
          unfortunately, that script is not under my control... and although it looks silly calling a variable "event", IE is absolutely more silly by allowing that to rewrite window.event!

          Anyway, for the moment, changing the script looks like the only viable solution...

          thanks everybody for your help! This just looks like another IE "feature" we will have to remember :)

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Originally posted by sdt76
            unfortunately, that script is not under my control... and although it looks silly calling a variable "event", IE is absolutely more silly by allowing that to rewrite window.event!

            Anyway, for the moment, changing the script looks like the only viable solution...

            thanks everybody for your help! This just looks like another IE "feature" we will have to remember :)
            True, I'll have to add it to the list of bugs. Thanks for bringing this up.

            Comment

            Working...