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 absolute path, not just the href attribute. Here's exactly what's happening: vars = $("a").attr("href"); alert(vars); <a href="page=2">This should return "page=2"</a> What I get when running locally in all browsers but IE is what is expected, an alert box with page=2 in it. In IE, I get "http:// localhost/page=2". Is there some way to get it to behave either one way or the other in all browser instances? I really don't want to have to detect for IE, then extract what I want from the string if it is.
http://www.glennjones.net/Post/809/getAttributehrefbug.htm describes the issue and gives a solution.
$("a")[0].href will probably work consistently. Regards, -- Martijn.