I am using prototype 1.6.0.3 and IE8.  Although I think the same
problem occurred in IE7. Why do the following lines of code give
errors?

<script type='text/javascript'>
 element = Element('div')  // Doesn't work when created this way.
 element.attachEvent('onclick', function(evt) {alert('hello')} ); //
can't attach event.
</script>

This doesn't work either:

<script type='text/javascript'>
  element = Element('div')
  Event.observe(element, 'click', function(evt) {alert('hello')});
</script>

However, when I do not use prototype to create the div element, both
of these do not generate errors:

<script type='text/javascript'>
 element = document.createElement('div');
 element.attachEvent('onclick', function(evt) {alert('hello')} );
</script>

<script type='text/javascript'>
 element = document.createElement('div');
 Event.observe(element, 'click', function(evt) {alert('hello')});
</script>


I was thinking that a div created with
  element = Element('div')
can do everything that a div created with
 element = document.createElement('div');
can do, but it will not allow me to attach an event for some reason.

Any ideas as far as why the first two don't work?

Thanks.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to