Wow. Had never seen that construct, very efficient. Learning something new everyday :)
cheers, - ricardo On Dec 21, 10:46 pm, "Michael Geary" <m...@mg.to> wrote: > I would think it would make more sense to do this in PHP instead of > JavaScript. You can use PHP code in your Drupal theme. > > If you want to do it in JavaScript, you don't need jQuery, regular > expressions, or indexOf. window.location (or just location) has several > properties that give you different pieces of the URL. location.pathname is > the one you want here. Note that it includes the leading slash. For example: > > var img = { > '/services': 'one-image.png', > '/about-us': 'another-image.png' > }[location.pathname] || 'default-image.png'; > > -Mike > > > From: Wonder95 > > > I"m sure this is easy to do, but I can't figure it out for > > some reason. I'm writing a simple little function in Drupal > > (in script.js in my theme) to display a different banner > > image (as a background for an element) based on the URL. So, > > for instance, if the URL ishttp://www.mysite.com/services, I > > want to display one image, if it's > >http://www.mysite.com/about-us, I want to display another > > one, and so on. Is there a built in way to get everything > > after "http://www.mysite.com/" in jQuery, or do I just need > > to use window.location and do something like use a regular > > expression to get what I need? > > > Thanks. > > > Steve