Phlip
2007-Jan-10 07:32 UTC
How to force a page that doesn''t want prototype.js to use it?
Railsers: Suppose I have a page inside an IFrame, and it knows nothing about Prototype.js. Now suppose I set the IFrames'' src to javascript:void(function(){ ... }) and put a big string of raw Javascript where that ... is. Now suppose that string wants to ping a server with new Ajax.Request. The JS source to foist prototype.js into an unwilling page reputedly looks like this: var newScript = document.createElement(''script''); newScript.type = "text/javascript"; newScript.src = "/javascripts/prototype.js"; document.getElementsByTagName(''head'')[0].appendChild(newScript); new Ajax.Request( ''/ctrl/action'', ...); That looks beautiful (for various definitions of "beautiful"), however it doesn''t seem to affect the scope of the current JS. My next experiment will foist first, with one src=javascript:void() line, and will then evaluate the new Ajax.Request on a second src=javascript:void() line. I''m curious if there''s a cleaner solution. (Note that project constraints forbid me to simply <script src=''...prototype.js''> in the target IFrame...) -- Phlip http://www.greencheese.us/ZeekLand <-- NOT a blog!!! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve
2007-Jan-10 07:44 UTC
Re: How to force a page that doesn''t want prototype.js to use it?
What I don''t understand is why on Earth you''d want to do regular AJAX from within an IFRAME that you apparently created dynamically. Regular AJAX is there to do away with IFRAME''s. Unless you''re not using IFRAME solely to do back-end comm, but to actually display stuff. But judging from your src attributes, it sure doesn''t look like it! -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---