steven-7G0WDI74SAFUbtYUoyoikg@public.gmane.org
2007-May-06 21:04 UTC
prototype setStyle (background-image) relative url problem
Hi there,
hope I can explain this one! When I try to use a setStyle call and set
the backgroundImage property of an element, I''m having some problems
using a relative URL.
my directory structure is this:
SERVER_ROOT/context/javascript/tree.js
SERVER_ROOT/context/style/tree/tree.css
SERVER_ROOT/context/images/node_icons/open.png
SERVER_ROOT/context/images/node_icons/closed.png
in my tree.css file i set background image using the relative
url: ../../images/node_icons/open.png
this works fine. However in my tree.js file I use the prototype
setStyle call and use the following:
nodeIconSpan.setStyle({backgroundImage:''url(../images/node_icons/
1nodeopen.gif)''});
this doesn''t work, it appears that the browser attempts to load from
SERVER_ROOT/images/node_icons/1nodeopen.gif
which is wrong (no ''context'').
I thought that maybe the image should be relative to the original css
file but that doesn''t work either. I can get it to work fine using an
absolute url but I''d really rather not do that.
Any ideas??
Many thanks.
Steven Shand
--~--~---------~--~----~------------~-------~--~----~
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-May-06 21:21 UTC
Re: prototype setStyle (background-image) relative url problem
You''re playing with the style DOM property, which means your base URI is that of your HTML page. So you must use URIs relative to the current HTML page indeed. Or use absolute. It''s nominal! -- 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 -~----------~----~----~----~------~----~------~--~---
stevenshand
2007-May-07 08:40 UTC
Re: prototype setStyle (background-image) relative url problem
Thanks for that. It seems so obvious now I can''t believe I didn''t try that option! Cheers again Steven On May 6, 10:21 pm, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote:> You''re playing with the style DOM property, which means your base URI is > that of your HTML page. So you must use URIs relative to the current > HTML page indeed. Or use absolute. It''s nominal! > > -- > Christophe Porteneuve a.k.a. TDD > "[They] did not know it was impossible, so they did it." --Mark Twain > Email: t...-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 -~----------~----~----~----~------~----~------~--~---