Hi, The following simple html doesn''t work with errors, why? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/ html4/strict.dtd"> <html> <title>click</title> <head> <h2>Click!</h2> <script type="text/javascript" language="javascript"> Event.observe(''myAnchor'', ''click'', function(e){ alert(''clicked me!'') }); </script> <a href="#null" id="myAnchor">1</a> </body> </html> Error: Event not define. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
cgusupport schrieb:> The following simple html doesn''t work with errors, why?You should load prototype.js if you want to use it ;-) <script type="text/javascript" src="path/to/prototype.js"></script> Frank -- "Laut einer Studie der deutschen Ärztevereinigung sterben immer mehr Rentner vor dem Computer. Sie drücken versehentlich die Tastenkombination Alt+Entfernen." http://www.landseer-stuttgart.de http://www.pn-cms.de --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
1: you need to include prototype.js 2: you should always define observers after the element is written in your code, i.e., *after* <a ... id="myAnchor">. To do this, either add your functions at the bottom of the page, or Event.observe(body, ''load'', function() { <FUNCTIONS> }); and add the functions in here. Edd On Sep 28, 11:18 pm, cgusupport <cgusupp...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > The following simple html doesn''t work with errors, why? > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/ > html4/strict.dtd"> > <html> > <title>click</title> <head> > <h2>Click!</h2> > <script type="text/javascript" language="javascript"> > Event.observe(''myAnchor'', ''click'', function(e){ alert(''clicked > me!'') }); > </script> > <a href="#null" id="myAnchor">1</a> > </body> > </html> > > Error: Event not define.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---