SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Jun 2005
    Posts
    260
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Image Refresh (dynamic src) doesn't work in IE6 (RESOLVED)

    Code:
    img.src = '/dynamic-image/?t=' + Math.random();
    The code above works in virtually every browser except for IE6.

    Update (Fix Found): I figured out what was causing the problem:

    I also had (which I didn't mention as I thought it insignificant):
    Code:
    img.setAttribute('href', 'javascript:;');
    which IE6 apparently has problems with. I changed it to:
    Code:
    img.setAttribute('href', '#');
    which fixed it.

    Note: As I didn't want the pound symbol showing up in the browser's URL address area, I returned false.

    Update 2: Big typo above
    As pmw57 points out, below, it doesn't make much sense to set a href attribute on the image. That's a typo. I actually meant to reference the link which triggers a onclick event that refreshes the image. The third post below explains this further.

    I'm going to leave the mistake in my original post untouched so others who visit this thread won't be confused.
    Last edited by champ; Mar 6, 2008 at 23:03.

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Why on earth are you setting the href attribute on an image?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Addict
    Join Date
    Jun 2005
    Posts
    260
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pmw57 View Post
    Why on earth are you setting the href attribute on an image?
    Yes, that doesn't make much sense, does it! I actually meant that I set the HREF on the link that triggers a onclick event which then refreshes the image.

    Snippet:
    Code:
    addRefreshLink: function()
    {
        var link = document.createElement('a');
        var linkText = document.createTextNode('Refresh Image');
            link.setAttribute('href', '#');
            link.appendChild(linkText);
        // other stuff irrelevent to this post...
    }


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •