<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Help needed with the javascript event model in Internet Explorer</title>
	<link>http://jonas.rabbe.com/archives/2005/05/09/help-needed-with-the-javascript-event-model-in-internet-explorer/</link>
	<description>My little piece of Internet heaven</description>
	<pubDate>Mon, 08 Sep 2008 17:11:40 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.2</generator>

	<item>
		<title>By: Chris Boulton</title>
		<link>http://jonas.rabbe.com/archives/2005/05/09/help-needed-with-the-javascript-event-model-in-internet-explorer/#comment-46</link>
		<author>Chris Boulton</author>
		<pubDate>Mon, 09 May 2005 12:31:28 +0000</pubDate>
		<guid>http://jonas.rabbe.com/archives/2005/05/09/help-needed-with-the-javascript-event-model-in-internet-explorer/#comment-46</guid>
		<description>Hey,

This is a tiny snipped of code from an XMLHttpRequest thing i'm working on for MyBB. Basically this code will return the element upon which an event was triggered upon in both IE and Mozilla based browsers..

Basically I have a variable for isMoz which is just a boolean identifying if the browser is Mozilla. This code will return the element based upon  event.currentTarget for Mozilla and event.srcElement for all other browsers.

As far as I can see this works fine..
&lt;code&gt;
function eventElement(event)
{
  if(isMoz)
  {
    return event.currentTarget;
  }
  else
  {
    return event.srcElement;
  }
}
&lt;/code&gt;

Basically you use it like..
&lt;code&gt;
	function handleClick(element)
	{
		textBox.value = eventElement(element).innerHTML;
	}
&lt;/code&gt;

In that example handleClick is the function attached to the onclick handler, and it inserts the HTML (which is just text) for the clicked element in to the textbox.

You should easily be able to adapt it for your own use.

Regards,
Chris</description>
		<content:encoded><![CDATA[<p>Hey,</p>
<p>This is a tiny snipped of code from an XMLHttpRequest thing i&#8217;m working on for MyBB. Basically this code will return the element upon which an event was triggered upon in both IE and Mozilla based browsers..</p>
<p>Basically I have a variable for isMoz which is just a boolean identifying if the browser is Mozilla. This code will return the element based upon  event.currentTarget for Mozilla and event.srcElement for all other browsers.</p>
<p>As far as I can see this works fine..<br />
<code><br />
function eventElement(event)<br />
{<br />
  if(isMoz)<br />
  {<br />
    return event.currentTarget;<br />
  }<br />
  else<br />
  {<br />
    return event.srcElement;<br />
  }<br />
}<br />
</code></p>
<p>Basically you use it like..<br />
<code><br />
	function handleClick(element)<br />
	{<br />
		textBox.value = eventElement(element).innerHTML;<br />
	}<br />
</code></p>
<p>In that example handleClick is the function attached to the onclick handler, and it inserts the <span class="caps">HTML</span> (which is just text) for the clicked element in to the textbox.</p>
<p>You should easily be able to adapt it for your own use.</p>
<p>Regards,<br />
Chris</p>
]]></content:encoded>
	</item>
</channel>
</rss>
