Loading ...
Sorry, an error occurred while loading the content.

Internet Explorer loads a single image X times

Expand Messages
  • keos_keos
    I m building a Tree Widget with the YUI library. I m using a few functions to simplify the coding, and it works out great. The Javascript code is shown on the
    Message 1 of 2 , Aug 31, 2007
    View Source
    • 0 Attachment
      I'm building a Tree Widget with the YUI library.
      I'm using a few functions to simplify the coding, and it works out
      great. The Javascript code is shown on the screen.

      The problem is, that IE6 loads the same image every time it creates a
      link. That's a HUGE overhead. IE7 is slow on this, but still manages
      to do the task. I don't know how many times it loads the image.

      Any ideas how I can fix this, to make the code load fast?


      var tmpNode = buildTreeTrunk(buildRow("Test", 270), root);
      var tmpNode = buildTreeTrunk(buildRow("Test", 271), root);

      function buildTreeTrunk(html, node) {
      var newnode = new YAHOO.widget.HTMLNode(html, node, false, true);
      return newnode;
      }

      function buildRow(label, number) {
      var row = "";
      row = buildLink('admin/sections/view/' + number, label, false);
      row += buildLink('admin/sections/edit/' + number + '/', $ImgDir +
      "edit.gif", true);
      row += buildLink('admin/sections/delete/' + number + '/', $ImgDir +
      "delete.gif", true);

      return row;
      }
      function buildLink(href, label, imageonly) {
      var code = "";

      if(imageonly==false)
      code = '<div class="treelink"><a href="' + $BaseURL + href + '">' +
      label + '</a></div>';
      else
      code = '<a href="' + $BaseThemeURL + href + '"><img src="' + label
      + '" /></a>';
      return code;
      }
    • someguynameddylan
      Create an image object and set the source to the url of the image. i.e: var imgObj = new Image(); imgObj.src = http://not.a.url/img.gif ; that will at least
      Message 2 of 2 , Sep 1, 2007
      View Source
      • 0 Attachment
        Create an image object and set the source to the url of the image.

        i.e:
        var imgObj = new Image();
        imgObj.src = "http://not.a.url/img.gif";

        that will at least cache it in the browser and minimize those i.e
        requests.

        --- In ydn-javascript@yahoogroups.com, "keos_keos" <keos_keos@...>
        wrote:
        >
        > I'm building a Tree Widget with the YUI library.
        > I'm using a few functions to simplify the coding, and it works out
        > great. The Javascript code is shown on the screen.
        >
        > The problem is, that IE6 loads the same image every time it creates
        a
        > link. That's a HUGE overhead. IE7 is slow on this, but still manages
        > to do the task. I don't know how many times it loads the image.
        >
        > Any ideas how I can fix this, to make the code load fast?
        >
        >
        > var tmpNode = buildTreeTrunk(buildRow("Test", 270), root);
        > var tmpNode = buildTreeTrunk(buildRow("Test", 271), root);
        >
        > function buildTreeTrunk(html, node) {
        > var newnode = new YAHOO.widget.HTMLNode(html, node, false,
        true);
        > return newnode;
        > }
        >
        > function buildRow(label, number) {
        > var row = "";
        > row = buildLink('admin/sections/view/' + number, label,
        false);
        > row += buildLink('admin/sections/edit/' + number + '/',
        $ImgDir +
        > "edit.gif", true);
        > row += buildLink('admin/sections/delete/' + number + '/',
        $ImgDir +
        > "delete.gif", true);
        >
        > return row;
        > }
        > function buildLink(href, label, imageonly) {
        > var code = "";
        >
        > if(imageonly==false)
        > code = '<div class="treelink"><a href="' + $BaseURL +
        href + '">' +
        > label + '</a></div>';
        > else
        > code = '<a href="' + $BaseThemeURL + href + '"><img
        src="' + label
        > + '" /></a>';
        > return code;
        > }
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.