[jQuery] Re: attr(href) giving full path instead of relative in IE

2009-03-26 Thread Rostislav Hristov
I experienced the same problem while developing a plugin that does some tricks with the page content during the ready event. I noticed that attr('href') works fine if I don't manipulate the body tag content. IE won't return the correct href attribute if I do so. The code I used to workaround the

[jQuery] Re: attr(href) giving full path instead of relative in IE

2009-03-25 Thread Martijn Houtman
On Mar 25, 2009, at 4:32 PM, Shane Riley wrote: I'm wanting to read in the exact string that's contained in an anchor's href attribute in order to use it as the POST variable list for an Ajax call to a PHP script, however in IE6 and 7 the string read from the href attribute ends up being the

[jQuery] Re: attr(href) giving full path instead of relative in IE

2009-03-25 Thread Shane Riley
Thanks for the article link, but your proposed change isn't valid JQuery, is it? My exact jQuery code to read in the value looks like this: pageID = $(this).attr(href); Adding what you suggested to make it $(this)[0].attr(href) will not do anything apart from force the link to be followed. I

[jQuery] Re: attr(href) giving full path instead of relative in IE

2009-03-25 Thread Martijn Houtman
On Mar 25, 2009, at 5:04 PM, Shane Riley wrote: Thanks for the article link, but your proposed change isn't valid JQuery, is it? My exact jQuery code to read in the value looks like this: pageID = $(this).attr(href); Adding what you suggested to make it $(this)[0].attr(href) will not do

[jQuery] Re: attr(href) giving full path instead of relative in IE

2009-03-25 Thread Shane Riley
Ha! I looked at your post too fast, and didn't notice that it was pure Javascript. Sorry. I'll try it and see. The way I currently have it will not work with javascript turned off either. I'm doing it this way only because the client is requiring the user to have Javascript enabled to use the

[jQuery] Re: attr(href) giving full path instead of relative in IE

2009-03-25 Thread Karl Swedberg
Hi Shane, IE has a second flag argument for getAttribute that, when set to 2, is supposed to get the literal value of the attribute rather than their special-sauce value. So, this.getAttribute('href', 2) *should* get the relative href. (note: no need to do $(this)[0] ; this works just

[jQuery] Re: attr(href) giving full path instead of relative in IE

2009-03-25 Thread Shane Riley
Karl, I'm pretty sure I'm reading you right, but are you saying that by all accounts JQuery should account for this and return the string- literal value of href and not IE's absolute path? If so, it's not working properly. I wish I could show you the live code, because it's probably easier to

[jQuery] Re: attr(href) giving full path instead of relative in IE

2009-03-25 Thread Shane Riley
After replacing $(this).attr(href) with this.getAttribute(href, 2) I get the same result. If I output the attribute, IE still shows the absolute path. On Mar 25, 2:21 pm, Shane Riley shanerileydoti...@gmail.com wrote: Karl, I'm pretty sure I'm reading you right, but are you saying that by all

[jQuery] Re: attr(href) giving full path instead of relative in IE

2009-03-25 Thread Karl Swedberg
Hi Shane, Yes, I believe you're reading me right. Strange, though. I'm not able to reproduce the problem you're having. Take a look here: http://test.learningjquery.com/href.html In IE 7 for #1 and #2 $(this).attr('href') is reporting the actual text string of the href attribute while

[jQuery] Re: attr(href) giving full path instead of relative in IE

2009-03-25 Thread Shane Riley
Alright, so your example shows the actual strings for all three values in Safari, and in IE7(Vista) it shows the absolute path for #3. After looking back at my code, I'm actually loading in the links via Ajax when the page is loaded, so they're not in the original document. So I'm guessing that

[jQuery] Re: attr(href) giving full path instead of relative in IE

2009-03-25 Thread Karl Swedberg
Well, the string manipulation is pretty minimal. Just use this.pathname -- or some combination of this.pathname, this.hash, and this.search if necessary. The one problem with this.pathname is that IE and Opera omit the initial slash while FF and Safari include it. But that's not hard to

[jQuery] Re: attr(href) giving full path instead of relative in IE

2009-03-25 Thread Shane Riley
Right, it's not hard, it was just unexpected is all. I guess I've gotten used to JQuery working the same in all browsers. I've got it working now with some old-fashioned Javascript. Thanks! On Mar 25, 3:20 pm, Shane Riley shanerileydoti...@gmail.com wrote: Alright, so your example shows the