replacing an onclick event

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Livermore

    replacing an onclick event

    From javascript in IE, I have a need to hijack the onclick event for
    an element and replace it dynamically with my own.

    I have tried the following...

    control.onclick = 'myHandler();';

    but this doesn't seem to do the trick. How do I go about doing this?

    Thanks,
    John
  • Lasse Reichstein Nielsen

    #2
    Re: replacing an onclick event

    John Livermore <john.livermore @nospm-inginix.com> writes:
    [color=blue]
    > From javascript in IE, I have a need to hijack the onclick event for
    > an element and replace it dynamically with my own.[/color]
    [color=blue]
    > I have tried the following...[/color]
    [color=blue]
    > control.onclick = 'myHandler();';
    >
    > but this doesn't seem to do the trick. How do I go about doing this?[/color]

    You have to assign a function.
    Try
    control.onclick = myHandler;

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • Lee

      #3
      Re: replacing an onclick event

      John said:[color=blue]
      >
      >From javascript in IE, I have a need to hijack the onclick event for
      >an element and replace it dynamically with my own.
      >
      >I have tried the following...
      >
      >control.onclic k = 'myHandler();';
      >
      >but this doesn't seem to do the trick. How do I go about doing this?[/color]

      control.onclick =myHandler;

      You're not replacing an event, you're replacing an event handler.
      Event handlers are functions, not strings.

      Comment

      • Phil N

        #4
        Re: replacing an onclick event

        John Livermore wrote:[color=blue]
        > From javascript in IE, I have a need to hijack the onclick event for
        > an element and replace it dynamically with my own.
        >
        > I have tried the following...
        >
        > control.onclick = 'myHandler();';
        >
        > but this doesn't seem to do the trick. How do I go about doing this?
        >
        > Thanks,
        > John[/color]

        captureEvents ???

        --

        --
        Phil Newcombe - philn?telus?net


        Netscape/Gecko/Mozilla - standards conformance and cooperation
        Internet Explorer - standards obfuscation and divergence
        Linux += 30,000/Germany + 80,000/Spain + tomorrow

        Comment

        Working...