Is there a possibility to get the information of the <script>-Tag inside a Prototype-Class? E.g.: <script id="myId"> var Animal = Class.create({ initialize: function(name, sound) { this.name = name; this.sound = sound; } }); </script> Can I get the id-information ("myId") of <script> inside the Animal- class? Thanks for comments! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Of course U can. just by calling $(''myId''). --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> Of course U can. just by calling $(''myId'').Ok, thats not what I meant ... ;-) I DO NOT have the id, that´s why I WANT it! So my desired goal is to get any information out of the <script>-Tag, like "id", "language", "refer", etc. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
for example <script id="myScriptTag" language="text/javascript" src="path/to/src"> ... ... ... //thosands lines of code after </script> you can get the language information $(''myScriptTag'').readAttribute(''language''); On Fri, Feb 15, 2008 at 7:11 AM, ohneworte <alexander.gewessler-Tswl7xcH0yE@public.gmane.org> wrote:> > > Of course U can. just by calling $(''myId''). > Ok, thats not what I meant ... ;-) > > I DO NOT have the id, that´s why I WANT it! > So my desired goal is to get any information out of the <script>-Tag, > like "id", "language", "refer", etc. > > >-- {a human being that was given to fly} --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
oh! sorry i didn''t read "I DO NOT HAVE the id" well then a solution could be getting all the script tags in the document $$(''script'').each(function(e){ var id = $(e).identify(); alert((e).readAttribute(''language'')); }); http://www.prototypejs.org/api/element/identify On Fri, Feb 15, 2008 at 8:49 AM, Elden <willy.d7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> for example > > <script id="myScriptTag" language="text/javascript" src="path/to/src"> > ... > ... > ... > //thosands lines of code after > </script> > you can get the language information > > $(''myScriptTag'').readAttribute(''language''); > > > On Fri, Feb 15, 2008 at 7:11 AM, ohneworte <alexander.gewessler-Tswl7xcH0yE@public.gmane.org> > wrote: > > > > > > Of course U can. just by calling $(''myId''). > > Ok, thats not what I meant ... ;-) > > > > I DO NOT have the id, that´s why I WANT it! > > So my desired goal is to get any information out of the <script>-Tag, > > like "id", "language", "refer", etc. > > > > > > > > > -- > {a human being that was given to fly}-- {a human being that was given to fly} --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I figured out, that I described my Problem in a wrong way. This is my scenario: HTML: <script id="myId"> new Animal(''Dog'',''Wuff''); </script> Thats somewhere in my JavaScript: var Animal = Class.create({ initialize: function(name, sound) { this.name = name; this.sound = sound; // HERE I WANT TO GET THE ID OF THE SCRIPT, THAT CALLED THIS CLASS } }); Consider the comment ... Thanks for information! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Feb 27, 10:04 pm, ohneworte <alexander.gewess...-Tswl7xcH0yE@public.gmane.org> wrote:> I figured out, that I described my Problem in a wrong way. This is my > scenario: > > HTML: > <script id="myId">ID is not a valid attribute for script elements in HTML 4.> new Animal(''Dog'',''Wuff''); > </script> > > Thats somewhere in my JavaScript: > var Animal = Class.create({ > initialize: function(name, sound) { > this.name = name; > this.sound = sound; > // HERE I WANT TO GET THE ID OF THE SCRIPT, THAT CALLED THIS CLASS > }You can attempt to identify the script element by executing global code that simply grabs the last script element in the document. The assumption is that the code must be in the last one. However, that method is very unreliable. As far as I know, there are no others. If you control the page, surely you know which script element your code is in? Anyhow, what do you expect to achieve by removing the script element? -- Rob --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> ID is not a valid attribute for script elements in HTML 4.I know, but it doesn´t matter in this case. I just need "something" to identify the <script>-Tag.> Anyhow, what do you expect to achieve by removing the script element?I don´t want to remove the element. My goal is to add HTML-Elements dynamically after the script-Tag. That ´s why I need the id or something else to identify it ... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
A <script> tag is not a visual HTML tag, it doesn''t have a position in the DOM (in the traditional sense) so you shouldn''t use if for DOM manipulation. All your javascript within the <script> tag is executing in the global scope, the same as if you had the <script> tag in the head. If you need to add something to the page, select a visual HTML tag(A,BR,H1,DIV,SPAN,OL,LI,etc.) and position your dynamic element based on that. Example: <html> <head> <script type="text/javascript" src="prototype.js"></script> <script type="text/javascript"> Event.observe(window, ''load'', function(){ var newEl = new Element("BR"); $(''someElement'').insert(newEl); }); </script> </head> <div id="someElement"> <!-- Where I want to position my element --> </div> </html> Also, its considered poor form to put <script> tags within the <body> of your HTML. I hope I interpreted you question correctly. Good Luck. -Todd --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
How about creating a variable and change it''s value each time one of your dynamically generated scripts are created. <script> var me = ''1''; ...do your stuff here... </script> ...more code or what not... <script> var me = ''2''; ... do your stuff here... </script> Greg On Feb 27, 2008, at 8:01 AM, ohneworte wrote:> >> ID is not a valid attribute for script elements in HTML 4. > I know, but it doesn´t matter in this case. I just need "something" to > identify the <script>-Tag. > >> Anyhow, what do you expect to achieve by removing the script element? > I don´t want to remove the element. > > My goal is to add HTML-Elements dynamically after the script-Tag. That > ´s why I need the id or something else to identify it ... > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Good proposal, but I want to provide my classes/functions/etc. to other developers, why a workaround like this should be avoided. Hmm, ... On 27 Feb., 18:57, Greg Hemphill <gregl...-Os9gbmDpkZVBDgjK7y7TUQ@public.gmane.org> wrote:> How about creating a variable and change it''s value each time one of > your dynamically generated scripts are created. > > <script> > var me = ''1''; > > ...do your stuff here... > </script> > > ...more code or what not... > > <script> > var me = ''2''; > > ... do your stuff here... > </script> > > Greg > > On Feb 27, 2008, at 8:01 AM, ohneworte wrote: > > > > >> ID is not a valid attribute for script elements in HTML 4. > > I know, but it doesn´t matter in this case. I just need "something" to > > identify the <script>-Tag. > > >> Anyhow, what do you expect to achieve by removing the script element? > > I don´t want to remove the element. > > > My goal is to add HTML-Elements dynamically after the script-Tag. That > > ´s why I need the id or something else to identify it ...--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---