I tried it too, and jquery is not consistent in handling the href/src
attribute in IE. I don't know why it is giving the absolute url when
<a>/<img> tags are loaded via ajax.

@MorningZ , the topic you have linked to, suggests that using $
(this).attr("href") will always give the actual text in href attribute
and not the absolute url, but that is only partially true, if the link/
image is loaded via ajax call, then in IE it gives the absolute url.
The same is true for "src" attribute too.

I hope the jquery team finds a way to fix this.

Spaceage

In the meantime how about using something like this, I know this is
not as concise as your version, but it will work independat of the
browser.

arrOldImage = $(this).attr("src").split("/");
        arrOldImage[arrOldImage.length-1] = arrOldImage
[arrOldImage.length-1].split(".").join("-hover.");
        newImage = arrOldImage.join("/");
        $(this).attr("src",newImage);

ksun


On Jan 29, 9:26 am, MorningZ <morni...@gmail.com> wrote:
> I wouldn't call it "strange", as IE automatically appends the full
> domain name on any link
>
> anyways, this topic from earlier in the week deals with this exact
> issue
>
> http://groups.google.com/group/jquery-en/browse_thread/thread/7d53af6...
>
> On Jan 28, 10:49 pm, spaceage <spaceageliv...@gmail.com> wrote:
>
>
>
> > I have a hover script that implements image rollovers that goes like
> > this:
>
> > $(document).ready(function() {
> >   $("img.rollover").hover(function() {
> >     $(this).attr("src", $(this).attr("src").split(".").join("-
> > hover."));
> >   }, function() {
> >     $(this).attr("src", $(this).attr("src").split("-hover.").join
> > ("."));
> >   });
>
> > });
>
> > This works great in all browsers--I just use a class="rollover" on the
> > <img> and name the rollover image with a "-hover" before the
> > extension.
>
> > Oddly, in IE6/7, when I jQuery "load" a <div> with new <img> elements
> > and reapply the hover function to the new <img> elements, IE gets
> > screwed up on the "src" setting.  It seems that IE uses the full
> > domain name as the source, and so my src ends up incorrect as "-
> > hover." gets appended to every item in the src prior to a ".".
>
> > eg:
>
> > after a load command (where the src attributes are relative, ie. '/
> > images/myimage.jpg'), I end up with an image src of:
>
> >http://www-hover.mysite-hover.com/images/myimage-hover.jpg
>
> > This only happens on IE 6/7 and only after a load event.
>
> > I use the exact same code on normal http page fetch to build these
> > images in my <div>, and this script works fine--the -hover only gets
> > appended at the file name of the src.
>
> > Does anybody have any idea why this is happening in IE?  Thanks in
> > advance.- Hide quoted text -
>
> - Show quoted text -

Reply via email to