[jQuery] Re: How to get parts of URL after domain

2009-01-05 Thread Cerebral
If you prefer to handle it with jQuery, you could also use the URL parser plugin: http://projects.allmarkedup.com/jquery_url_parser/ . Though, Michael solution is quite elegant.

[jQuery] Re: How to get parts of URL after domain

2008-12-22 Thread Wonder95
Could you explain that construct? I'm no JS expert, and I haven't seen it before. Thanks. 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.

[jQuery] Re: How to get parts of URL after domain

2008-12-22 Thread Michael Geary
Sure, it's just a combination of some other JavaScript features that may look more familiar if we take them one by one: // Use an object literal to create an object // with two properties. Each property has // a name and a value.     var images = {         '/services':

[jQuery] Re: How to get parts of URL after domain

2008-12-22 Thread Wonder95
OK, so if I try using that to set my banner, I come up with something like this: var img = { '/ops/content/services': 'banner2.jpg', '/ops/content/services': 'banner3.jpg', }[location.pathname] || 'banner1.jpg'; $(td#header).css(background,url(/ops/sites/all/themes/

[jQuery] Re: How to get parts of URL after domain

2008-12-22 Thread Michael Geary
Steve, now I'm really confused. Does it work like a charm, or do you keep getting an error? (Or both?) :-) BTW, you can write $(td#header) as just $(#header) and it may actually be faster because it will use a direct document.getElementById() lookup. Also, just a suggestion, if you get in the

[jQuery] Re: How to get parts of URL after domain

2008-12-21 Thread ripple
I'm not sure what happened there with my multiple replies.   Sorry   --- On Sun, 12/21/08, Wonder95 killsho...@gmail.com wrote: From: Wonder95 killsho...@gmail.com Subject: [jQuery] How to get parts of URL after domain To: jQuery (English) jquery-en@googlegroups.com Date: Sunday, December 21,

[jQuery] Re: How to get parts of URL after domain

2008-12-21 Thread ripple
if (url.indexOf(services) 0) {   --- On Sun, 12/21/08, Wonder95 killsho...@gmail.com wrote: From: Wonder95 killsho...@gmail.com Subject: [jQuery] How to get parts of URL after domain To: jQuery (English) jquery-en@googlegroups.com Date: Sunday, December 21, 2008, 5:10 PM Im sure this is easy to

[jQuery] Re: How to get parts of URL after domain

2008-12-21 Thread ripple
if (url.indexOf(services) 0) { --- On Sun, 12/21/08, Wonder95 killsho...@gmail.com wrote: From: Wonder95 killsho...@gmail.com Subject: [jQuery] How to get parts of URL after domain To: jQuery (English) jquery-en@googlegroups.com Date: Sunday, December 21, 2008, 5:10 PM Im sure this is

[jQuery] Re: How to get parts of URL after domain

2008-12-21 Thread ripple
Why not get the url and test it?   if (url.indexOf(services) 0) {  do this } else if (url.indexOf(about-us) 0) {  do this } That's one way to do it.     http://2whoa.com/dominate     --- On Sun, 12/21/08, Wonder95 killsho...@gmail.com wrote: From: Wonder95 killsho...@gmail.com Subject:

[jQuery] Re: How to get parts of URL after domain

2008-12-21 Thread Michael Geary
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

[jQuery] Re: How to get parts of URL after domain

2008-12-21 Thread Ricardo Tomasi
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