Re: Append OnClick-Script to MathML-Tags

Frédéric Wang <[email protected]> Thu, 23 Sep 2010 17:42:11 +0200
Newsgroups gmane.comp.mozilla.devel.mathml
Message-ID <[email protected]>
I copy your mail to the mozilla mathml list since I suppose it was your 
intention (I'm not sure your problem is really mathml-specific though, 
and you can certainly find more help elsewhere).

I've not really read your code in details, but your function load(el) 
attach an "onclick"  listener to the element el. So you must call it 
after having loaded the page (for each element you want to track), not 
when the user clicks on the MathML elements (and anyway I don't think 
you can use the "onclick" attribute on them).

Le 23/09/2010 08:55, Tim a écrit :
 > Hej,
 >
 > I think I found a way, but I'm not really into the whole JavaScript 
thing...can anyone help me out? Heres the code:
 > <script type="text/javascript">
 >
 >    // Function to change the content of t2
 >    function sendRequest(Element e) {
 >      var req = new XMLHttpRequest();
 >
 >      var formData = new FormData();
 >
 > 	formData.append("element", e);
 >
 > 	xhr.open("POST", "http://test.com");
 > 	xhr.send(formData);
 >    }
 >
 >    // Function to add event listener to clicked Element
 >    function load(Element el) {
 >      el.addEventListener("click", function(){sendRequest(el);}, 
false);
 >    }
 >
 >    </script>
 >  <mfrac>
 > 	<mrow>
 > 		<mrow>
 > 			<mo onclick='load(this);'>(</mo>
 > 			<mn onclick="load(this);">2</mn>
 > 			<mo onclick="load(this);">&middot;</mo>
 > 			<mn>4</mn>
 > 			<mo>)</mo>
 > 		</mrow>
 > 	</mrow>
 > 	<mrow>
 > 	<mrow><mo>(</mo><mn>3</mn><mo>-</mo><mn>4</mn><mo>)</mo></mrow>
 > 	</mrow>
 >
 > My approch was creating a custom URL with the information about the 
element I need like "http://myApp:*heres the id*/*other information 
here*" Hope I made the point clear :)


Le 20/09/2010 08:26, Tim Specht a écrit :
> Hej guys,
>
> I need to be notified when the user clicks an element of my MathML-
> Rendering and I also need to know which it was. So it is possible to
> attach an onclick-script to MathML-Tags? Or is there at least
> something similar I could use?
> Thanks in advance,
> Tim Specht