Compare Revisions

GlobalEventHandlers.onclick

Revision 49713:

Revision 49713 by Dria on

Revision 49714:

Revision 49714 by Ettinger on

Title:
element.onclick
element.onclick
Slug:
DOM/element.onclick
DOM/element.onclick
Tags:
DOM, Gecko, "Gecko DOM Reference"
DOM, Gecko, "Gecko DOM Reference"
Content:

Revision 49713
Revision 49714
tt36    <p>
37      To dynamically change or add an "onclick" event handler to 
 >an element, try:
38    </p>
39    <pre>
40var el = document.getElementById('foo');
41el.onclick = showPopup;
42//NOTE: showPopup(); or showPopup(param); will NOT work here.
43//Must be a reference to a function, not a function call.
44 
45function showPopup()
46{
47  var popup = window.open(this.href, "popup", "height=800,width=6
 >00");
48  popup.focus();
49  return false;
50}
51</pre>

Back to History