Alex MacCaw
2007-Nov-06 07:42 UTC
new Element doesn''t work in Safari with Prototype 1.6.0_rc1
I''m encountering quite a weird problem with Safari 2.0.4 - ''new Element'' doesn''t work at all, *unless* you change the file extension of the document you''re loading from xhtml to html. Try rendering the code below using the different extensions: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/ TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript" src="http://www.prototypejs.org/ assets/2007/10/16/prototype.js"></script> <script type="text/javascript"> // <![CDATA[ function loadme() { var newelem = new Element(''div''); newelem.update("It worked."); $(document.body).insert(newelem) } Element.observe(window, ''load'', loadme) // ]]> </script> </head> <body> </body> </html> Does anyone know what the problem is? It seems a fairly fundamental issue with Safari & Prototype. Alex --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
RobG
2007-Nov-06 14:55 UTC
Re: new Element doesn''t work in Safari with Prototype 1.6.0_rc1
On Nov 6, 5:42 pm, Alex MacCaw <macc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m encountering quite a weird problem with Safari 2.0.4 - ''new > Element'' doesn''t work at all, *unless* you change the file extension > of the document you''re loading from xhtml to html.It seems that Safari uses the file extension rather than the DOCTYPE declaration. If you serve your file to Safari as XHTML, I suspect you will get the same result. Safari does not appear to support the (non-standard) innerHTML property for dynamically created elements in XML documents. If you try something like: alert(typeof newelem.innerHTML) you will get ''undefined'', whereas ''string'' would be expected if the innerHTML property was supported (and that is the result for an HTML document). [...]> Does anyone know what the problem is? It seems a fairly fundamental > issue with Safari & Prototype.Yes, it does, since Prototype is very dependent on innerHTML. But then again, using XHTML on the web is pretty much a complete waste of time. Incidentally, your document is not a valid XHTML document anyway, so strictly, if served as application/XML, the result should be an error message . -- 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 -~----------~----~----~----~------~----~------~--~---
Ed C.
2007-Nov-06 15:25 UTC
Re: new Element doesn''t work in Safari with Prototype 1.6.0_rc1
Take a look at the content-type header being sent by your web server, and/or adding a meta tag to your header and "hard coding" the content-type. On 11/6/07, RobG <rgqld-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org> wrote:> > > > > On Nov 6, 5:42 pm, Alex MacCaw <macc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I''m encountering quite a weird problem with Safari 2.0.4 - ''new > > Element'' doesn''t work at all, *unless* you change the file extension > > of the document you''re loading from xhtml to html. > > It seems that Safari uses the file extension rather than the DOCTYPE > declaration. If you serve your file to Safari as XHTML, I suspect you > will get the same result. > > Safari does not appear to support the (non-standard) innerHTML > property for dynamically created elements in XML documents. If you > try something like: > > alert(typeof newelem.innerHTML) > > you will get ''undefined'', whereas ''string'' would be expected if the > innerHTML property was supported (and that is the result for an HTML > document). > > [...] > > Does anyone know what the problem is? It seems a fairly fundamental > > issue with Safari & Prototype. > > Yes, it does, since Prototype is very dependent on innerHTML. But > then again, using XHTML on the web is pretty much a complete waste of > time. > > Incidentally, your document is not a valid XHTML document anyway, so > strictly, if served as application/XML, the result should be an error > message . > > > -- > 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 -~----------~----~----~----~------~----~------~--~---
Alex MacCaw
2007-Nov-07 11:06 UTC
Re: new Element doesn''t work in Safari with Prototype 1.6.0_rc1
Ok, it seems that I''ve been barking up the wrong tree. new Element(''div'') works in safari (if you specify the right content-type), but new Element(''div'', {class: ''cls''}) doesn''t. I presume Safari uses ''class'' for something else? Anyways, I now have a new problem, but I''ll post that in a separate thread. Thanks Alex On Nov 6, 2007 3:25 PM, Ed C. <defeated2k4-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Take a look at the content-type header being sent by your web server, > and/or adding a meta tag to your header and "hard coding" the content-type. > > > On 11/6/07, RobG <rgqld-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org> wrote: > > > > > > > > > > On Nov 6, 5:42 pm, Alex MacCaw <macc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I''m encountering quite a weird problem with Safari 2.0.4 - ''new > > > Element'' doesn''t work at all, *unless* you change the file extension > > > of the document you''re loading from xhtml to html. > > > > It seems that Safari uses the file extension rather than the DOCTYPE > > declaration. If you serve your file to Safari as XHTML, I suspect you > > will get the same result. > > > > Safari does not appear to support the (non-standard) innerHTML > > property for dynamically created elements in XML documents. If you > > try something like: > > > > alert(typeof newelem.innerHTML) > > > > you will get ''undefined'', whereas ''string'' would be expected if the > > innerHTML property was supported (and that is the result for an HTML > > document). > > > > [...] > > > Does anyone know what the problem is? It seems a fairly fundamental > > > issue with Safari & Prototype. > > > > Yes, it does, since Prototype is very dependent on innerHTML. But > > then again, using XHTML on the web is pretty much a complete waste of > > time. > > > > Incidentally, your document is not a valid XHTML document anyway, so > > strictly, if served as application/XML, the result should be an error > > message . > > > > > > -- > > Rob > > > > > > > > > >-- http://www.eribium.org | http://juggernaut.rubyforge.org | http://www.aireofs.com | Skype: oldmanorhouse --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Tobie Langel
2007-Nov-07 13:49 UTC
Re: new Element doesn''t work in Safari with Prototype 1.6.0_rc1
Hi, class is a reserved keyword in JavaScript. Prototype supports the two following notations: new Element(''div'', {''class'': ''cls''}); new Element(''div'', {className: ''cls''}); Regards, Tobie On Nov 7, 12:06 pm, "Alex MacCaw" <macc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Ok, it seems that I''ve been barking up the wrong tree. new Element(''div'') > works in safari (if you specify the right content-type), but new > Element(''div'', {class: ''cls''}) doesn''t. I presume Safari uses ''class'' for > something else? Anyways, I now have a new problem, but I''ll post that in a > separate thread. > Thanks > Alex > > On Nov 6, 2007 3:25 PM, Ed C. <defeated...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Take a look at the content-type header being sent by your web server, > > and/or adding a meta tag to your header and "hard coding" the content-type. > > > On 11/6/07, RobG <rg...-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org> wrote: > > > > On Nov 6, 5:42 pm, Alex MacCaw <macc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I''m encountering quite a weird problem with Safari 2.0.4 - ''new > > > > Element'' doesn''t work at all, *unless* you change the file extension > > > > of the document you''re loading from xhtml to html. > > > > It seems that Safari uses the file extension rather than the DOCTYPE > > > declaration. If you serve your file to Safari as XHTML, I suspect you > > > will get the same result. > > > > Safari does not appear to support the (non-standard) innerHTML > > > property for dynamically created elements in XML documents. If you > > > try something like: > > > > alert(typeof newelem.innerHTML) > > > > you will get ''undefined'', whereas ''string'' would be expected if the > > > innerHTML property was supported (and that is the result for an HTML > > > document). > > > > [...] > > > > Does anyone know what the problem is? It seems a fairly fundamental > > > > issue with Safari & Prototype. > > > > Yes, it does, since Prototype is very dependent on innerHTML. But > > > then again, using XHTML on the web is pretty much a complete waste of > > > time. > > > > Incidentally, your document is not a valid XHTML document anyway, so > > > strictly, if served as application/XML, the result should be an error > > > message . > > > > -- > > > Rob > > --http://www.eribium.org|http://juggernaut.rubyforge.org|http://www.aireofs.com| Skype: oldmanorhouse--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
RobG
2007-Nov-11 21:03 UTC
Re: new Element doesn''t work in Safari with Prototype 1.6.0_rc1
On Nov 7, 12:55 am, RobG <rg...-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org> wrote:> On Nov 6, 5:42 pm, Alex MacCaw <macc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I''m encountering quite a weird problem withSafari2.0.4 - ''new > > Element'' doesn''t work at all, *unless* you change the file extension > > of the document you''re loading from xhtml to html. > > It seems thatSafariuses the file extension rather than the DOCTYPE > declaration. If you serve your file toSafarias XHTML, I suspect you > will get the same result. > > Safaridoes not appear to support the (non-standard) innerHTML > property for dynamically created elements in XML documents.To use innerHTML with an XHTML document in Safari, you must use: document.createElementNS(''http://www.w3.org/1999/xhtml'', tagName); Further details and discussion are here: <URL: http://groups.google.com.au/group/comp.lang.javascript/browse_frm/thread/60c993dcbcd65b72/be77261c4bc3fb92?hl=en#be77261c4bc3fb92>-- 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 -~----------~----~----~----~------~----~------~--~---
I''m struggling a bit with the disparity between how Moz and IE handle selection in textarea objects. Does anyone have any prototype- leveraging code that encapsulates this kind of thing? The Moz part is pretty straightforward and I have it working. The IE stuff is a bit of a mystery to me. TIA, -s --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
selection to what end? On Nov 12, 2007 2:17 PM, s.ross <cwdinfo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I''m struggling a bit with the disparity between how Moz and IE handle > selection in textarea objects. Does anyone have any prototype- > leveraging code that encapsulates this kind of thing? The Moz part is > pretty straightforward and I have it working. The IE stuff is a bit > of a mystery to me. > > TIA, > > -s > > > >--~--~---------~--~----~------------~-------~--~----~ 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 want to create a special-purpose editor that does live previewing. It''s kind of UBB, but of course, all UBBs have their own peculiar syntaxes and use cases. Sample: - user selects text in textarea - user presses bold button in interface - text -> [b]text[/b] Nothing too fancy, just different in IE and the documentation is very sparse. Thought if someone on this list had some code lying around it would be worth knowing before I write it myself. Thx On Nov 12, 2007, at 11:21 AM, Brian Williams wrote:> selection to what end? > > > On Nov 12, 2007 2:17 PM, s.ross <cwdinfo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I''m struggling a bit with the disparity between how Moz and IE handle > selection in textarea objects. Does anyone have any prototype- > leveraging code that encapsulates this kind of thing? The Moz part is > pretty straightforward and I have it working. The IE stuff is a bit > of a mystery to me. > > TIA, > > -s > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
ah, ok... quick googling found http://www.webdeveloper.com/forum/showthread.php?t=118115 which lead to http://parentnode.org/javascript/working-with-the-cursor-position/ good luck and make sure you read through the comments and don''t just carbon copy the code cause its "wrong" but the code in the comments evidently make it much easier On Nov 12, 2007 2:36 PM, s.ross <cwdinfo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I want to create a special-purpose editor that does live previewing. It''s > kind of UBB, but of course, all UBBs have their own peculiar syntaxes and > use cases. > Sample: > > - user selects text in textarea > - user presses bold button in interface > - text -> [b]text[/b] > > Nothing too fancy, just different in IE and the documentation is very > sparse. Thought if someone on this list had some code lying around it would > be worth knowing before I write it myself. > > Thx > > On Nov 12, 2007, at 11:21 AM, Brian Williams wrote: > > selection to what end? > > > On Nov 12, 2007 2:17 PM, s.ross <cwdinfo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I''m struggling a bit with the disparity between how Moz and IE handle > > selection in textarea objects. Does anyone have any prototype- > > leveraging code that encapsulates this kind of thing? The Moz part is > > pretty straightforward and I have it working. The IE stuff is a bit > > of a mystery to me. > > > > TIA, > > > > -s > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks, I''ll check it out. I''ve turned up similar in Google, and they are really YMMV solutions. I''ll try to get a somewhat general solution and post it somewhere. My Moz implementation is to create a TextArea class to encapsulate this with the control as an instance variable. Does this make sense or should I be extending something? Thx On Nov 12, 2007, at 11:49 AM, Brian Williams wrote:> ah, ok... > > quick googling found > > http://www.webdeveloper.com/forum/showthread.php?t=118115 > > which lead to http://parentnode.org/javascript/working-with-the- > cursor-position/ > > good luck and make sure you read through the comments and don''t > just carbon copy the code > cause its "wrong" but the code in the comments evidently make it > much easier > > > > On Nov 12, 2007 2:36 PM, s.ross <cwdinfo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > I want to create a special-purpose editor that does live > previewing. It''s kind of UBB, but of course, all UBBs have their > own peculiar syntaxes and use cases. > > Sample: > > - user selects text in textarea > - user presses bold button in interface > - text -> [b]text[/b] > > Nothing too fancy, just different in IE and the documentation is > very sparse. Thought if someone on this list had some code lying > around it would be worth knowing before I write it myself. > > Thx > > On Nov 12, 2007, at 11:21 AM, Brian Williams wrote: > >> selection to what end? >> >> >> On Nov 12, 2007 2:17 PM, s.ross <cwdinfo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> I''m struggling a bit with the disparity between how Moz and IE handle >> selection in textarea objects. Does anyone have any prototype- >> leveraging code that encapsulates this kind of thing? The Moz part is >> pretty straightforward and I have it working. The IE stuff is a bit >> of a mystery to me. >> >> TIA, >> >> -s >> >> > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 Nov 12, 2007, at 3:00 PM, s.ross wrote:> Thanks, I''ll check it out. I''ve turned up similar in Google, and > they are really YMMV solutions. I''ll try to get a somewhat general > solution and post it somewhere. My Moz implementation is to create > a TextArea class to encapsulate this with the control as an > instance variable. Does this make sense or should I be extending > something? > > Thx > > On Nov 12, 2007, at 11:49 AM, Brian Williams wrote: >You might want to look at the LivePipe Control.TextArea editor widget. I have used that before, and it''s very nice. Does what you describe in a very Prototype-centric manner. Walter 1. http://livepipe.net/projects/control_textarea/ --~--~---------~--~----~------------~-------~--~----~ 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 Nov 12, 2007, at 6:13 PM, Walter Lee Davis wrote:> You might want to look at the LivePipe Control.TextArea editor > widget. I have used that before, and it''s very nice. Does what you > describe in a very Prototype-centric manner. > > Walter > > 1. http://livepipe.net/projects/control_textarea/Great pointer. Just needed a few methods and it worked! --s --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---