How to evaluate an onClick attribute of an element

I have this table comprised of many rows, and I want to be able to run onClick

functions through the keyboard. For simplicity's sake, i'm only going to put

one row in this table. Bear in mind that there are many more.

Heres my simplified table:

<table>
      <tr id="row1" onClick="mark('event1',true,false,false)">
            <td>Just some text here</td>
      </tr>
</table>



so, running this onClick element in FireFox is easy, i just run the following

code:

<script>
      // mozilla fire fox code
      eval(document.getElementById("row1").getAttribute("onClick"));
</script>



However, in IE, it doesn't seem to work. here's what i have tried in IE

without success:

<script>
      // First attempt in IE w/o success
      eval(document.getElementById("row1").getAttribute("onClick"));
      
      // Second attempt in IE w/o success
      eval(document.getElementById("row1").onclick);

      //Third attemp in IE w/o success
      eval(eval(document.getElementById("row1").onclick));
</script>


Now, i ran some alerts in FireFox and IE to see what these two functions

(getAttribute and onclick) were returning. here are the resuts:

<script>

      alert(document.getElementById("row1").onclick);
      /* FF Output:
            function onclick(event){
            mark("event1",true,false,false);
            }
      */
      /* IE Output:
            function anonymous()
            {
            mark("event1",true,false,false);
            }
      */

      alert(documet.getElementById("row1").getAttribute("onClick"));
      /* FF Output:
            mark("event1",true,false,false);
      */
      /* IE Output:
            function anonymous()
            {
            mark("event1",true,false,false);
            }
      */
</script>


Does anyone know how i can get this working in IE?

thanks,
iqDevs
iqDevsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

iqDevsAuthor Commented:
okay, i figured it out:

<script>
      document.getElementById("row1").onclick();
</script>

didn't know it was this easy. works great in IE and FF.
SnowFlakeCommented:
an alternative approache would be to have the onclick handlers call a function
and from your script handler call the same function.

what is the best way depends on what exactly are your needs
and there is not enough info here to evaluate.

SnowFlake.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.