Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Images Won't display in IE 7

Images Won't display in IE 7

Scheduled Pinned Locked Moved JavaScript
javascripthtmldata-structurestoolsquestion
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PianoMan
    wrote on last edited by
    #1

    Would someone please tell me why this js won't display images in IE 7, but works perfectly in Firefox? I'm using Windows XP, and I've double-checked all my settings in IE 7. Thanks!

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>Sample</TITLE>

    <SCRIPT LANGUAGE="JavaScript">
    window.onload = fnWrite;

    function fnWrite()
    {
    // Declare variables
    var vTable = document.createElement("TABLE");
    var vTBody = document.createElement("TBODY");
    var vRow, vCell, vDiv, vImg;
    var i;

    var images = new Array();
    images[0] = "images/treble_f1.JPG";
    images[1] = "images/treble_c1.JPG";
    images[2] = "images/treble_d1.JPG";
    images[3] = "images/treble_e1.JPG";

    // Insert vBody into vTable
    vTable.appendChild(vTBody);

    // Insert a row
    vRow = document.createElement("TR");
    vTBody.appendChild(vRow);
    vCell = document.createElement("TD");
    vRow.appendChild(vCell);

    // Insert images
    for (i=0; i<images.length; i++)
    {
    vDiv = document.createElement("DIV");
    vCell.appendChild(vDiv);

    vImg = document.createElement("IMG");
    vImg.src = images\[i\];
    vImg.setAttribute("alt", "image");
    vCell.appendChild(vImg);
    

    }
    // Insert the table
    vTableContainer.appendChild(vTable);
    }
    </SCRIPT>

    </HEAD>
    <BODY>
    <H1>Javascript Won't Work in IE 7</H1>
    <div id="vTableContainer"></div>

    </BODY>
    </HTML>

    L J T 3 Replies Last reply
    0
    • P PianoMan

      Would someone please tell me why this js won't display images in IE 7, but works perfectly in Firefox? I'm using Windows XP, and I've double-checked all my settings in IE 7. Thanks!

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
      <HTML>
      <HEAD>
      <TITLE>Sample</TITLE>

      <SCRIPT LANGUAGE="JavaScript">
      window.onload = fnWrite;

      function fnWrite()
      {
      // Declare variables
      var vTable = document.createElement("TABLE");
      var vTBody = document.createElement("TBODY");
      var vRow, vCell, vDiv, vImg;
      var i;

      var images = new Array();
      images[0] = "images/treble_f1.JPG";
      images[1] = "images/treble_c1.JPG";
      images[2] = "images/treble_d1.JPG";
      images[3] = "images/treble_e1.JPG";

      // Insert vBody into vTable
      vTable.appendChild(vTBody);

      // Insert a row
      vRow = document.createElement("TR");
      vTBody.appendChild(vRow);
      vCell = document.createElement("TD");
      vRow.appendChild(vCell);

      // Insert images
      for (i=0; i<images.length; i++)
      {
      vDiv = document.createElement("DIV");
      vCell.appendChild(vDiv);

      vImg = document.createElement("IMG");
      vImg.src = images\[i\];
      vImg.setAttribute("alt", "image");
      vCell.appendChild(vImg);
      

      }
      // Insert the table
      vTableContainer.appendChild(vTable);
      }
      </SCRIPT>

      </HEAD>
      <BODY>
      <H1>Javascript Won't Work in IE 7</H1>
      <div id="vTableContainer"></div>

      </BODY>
      </HTML>

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Try moving the line

      window.onload = fnWrite;

      after the fnWrite() function block.

      Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

      P 1 Reply Last reply
      0
      • L Lost User

        Try moving the line

        window.onload = fnWrite;

        after the fnWrite() function block.

        Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

        P Offline
        P Offline
        PianoMan
        wrote on last edited by
        #3

        Thanks for the reply, however that did not fix this problem. The IE browser does display the little thumbnail box, which tells me the image tag is there, but this line of code vImg.src = images[i]; for some reason is not setting the source for the image. I've even tried hard coding in the source with no luck.

        L 1 Reply Last reply
        0
        • P PianoMan

          Thanks for the reply, however that did not fix this problem. The IE browser does display the little thumbnail box, which tells me the image tag is there, but this line of code vImg.src = images[i]; for some reason is not setting the source for the image. I've even tried hard coding in the source with no luck.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Sorry, it was a bit of a stab in the dark, but I know that there are some strange inconsistencies between IE and the other browsers.

          Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

          P 1 Reply Last reply
          0
          • L Lost User

            Sorry, it was a bit of a stab in the dark, but I know that there are some strange inconsistencies between IE and the other browsers.

            Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

            P Offline
            P Offline
            PianoMan
            wrote on last edited by
            #5

            Thanks for the reply. Well, I removed the javascript from the HTML page and put it in a js file, and now it works. Go figure... Thanks a lot, Microsoft. :(

            L 1 Reply Last reply
            0
            • P PianoMan

              Thanks for the reply. Well, I removed the javascript from the HTML page and put it in a js file, and now it works. Go figure... Thanks a lot, Microsoft. :(

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              This[^] may help explain things.

              Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

              1 Reply Last reply
              0
              • P PianoMan

                Would someone please tell me why this js won't display images in IE 7, but works perfectly in Firefox? I'm using Windows XP, and I've double-checked all my settings in IE 7. Thanks!

                <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
                <HTML>
                <HEAD>
                <TITLE>Sample</TITLE>

                <SCRIPT LANGUAGE="JavaScript">
                window.onload = fnWrite;

                function fnWrite()
                {
                // Declare variables
                var vTable = document.createElement("TABLE");
                var vTBody = document.createElement("TBODY");
                var vRow, vCell, vDiv, vImg;
                var i;

                var images = new Array();
                images[0] = "images/treble_f1.JPG";
                images[1] = "images/treble_c1.JPG";
                images[2] = "images/treble_d1.JPG";
                images[3] = "images/treble_e1.JPG";

                // Insert vBody into vTable
                vTable.appendChild(vTBody);

                // Insert a row
                vRow = document.createElement("TR");
                vTBody.appendChild(vRow);
                vCell = document.createElement("TD");
                vRow.appendChild(vCell);

                // Insert images
                for (i=0; i<images.length; i++)
                {
                vDiv = document.createElement("DIV");
                vCell.appendChild(vDiv);

                vImg = document.createElement("IMG");
                vImg.src = images\[i\];
                vImg.setAttribute("alt", "image");
                vCell.appendChild(vImg);
                

                }
                // Insert the table
                vTableContainer.appendChild(vTable);
                }
                </SCRIPT>

                </HEAD>
                <BODY>
                <H1>Javascript Won't Work in IE 7</H1>
                <div id="vTableContainer"></div>

                </BODY>
                </HTML>

                J Offline
                J Offline
                jsc42
                wrote on last edited by
                #7

                box or the 4 symbol box but if I show the source, save it, run the saved version the images come up correctly. Are you using IE automation or simple file opening?

                1 Reply Last reply
                0
                • P PianoMan

                  Would someone please tell me why this js won't display images in IE 7, but works perfectly in Firefox? I'm using Windows XP, and I've double-checked all my settings in IE 7. Thanks!

                  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
                  <HTML>
                  <HEAD>
                  <TITLE>Sample</TITLE>

                  <SCRIPT LANGUAGE="JavaScript">
                  window.onload = fnWrite;

                  function fnWrite()
                  {
                  // Declare variables
                  var vTable = document.createElement("TABLE");
                  var vTBody = document.createElement("TBODY");
                  var vRow, vCell, vDiv, vImg;
                  var i;

                  var images = new Array();
                  images[0] = "images/treble_f1.JPG";
                  images[1] = "images/treble_c1.JPG";
                  images[2] = "images/treble_d1.JPG";
                  images[3] = "images/treble_e1.JPG";

                  // Insert vBody into vTable
                  vTable.appendChild(vTBody);

                  // Insert a row
                  vRow = document.createElement("TR");
                  vTBody.appendChild(vRow);
                  vCell = document.createElement("TD");
                  vRow.appendChild(vCell);

                  // Insert images
                  for (i=0; i<images.length; i++)
                  {
                  vDiv = document.createElement("DIV");
                  vCell.appendChild(vDiv);

                  vImg = document.createElement("IMG");
                  vImg.src = images\[i\];
                  vImg.setAttribute("alt", "image");
                  vCell.appendChild(vImg);
                  

                  }
                  // Insert the table
                  vTableContainer.appendChild(vTable);
                  }
                  </SCRIPT>

                  </HEAD>
                  <BODY>
                  <H1>Javascript Won't Work in IE 7</H1>
                  <div id="vTableContainer"></div>

                  </BODY>
                  </HTML>

                  T Offline
                  T Offline
                  twseitex
                  wrote on last edited by
                  #8

                  A massive problem of Microsoft If you want reders animated gifs then that will by chrashed by Internet Explorer preload img with '?' after suffix (:gif?) have no result: animated gif even not rendered. e.g. // X00 is an existing image object // X01 is an existing preloaded image object with filled .src of an animated gif X00.src=X01.src+'?'; // only if IE exists X00.src=X01.src; // for opera etc. preload image var imgObjekt1=new Image(); // height and width if you want imgObjekt1.src='animated.gif'; // maybe with path, but not with '?' vImg = document.createElement("IMG"); // check pionter ! if(vImg!=null) { // append into object (into child of body) // append into collection images automatically // check pointer of appended object, use e.g. var imgAppendedImgObject if(imgAppendedImgObject!=null) {imgAppendedImgObject.src=imgObjekt1.src+'?'; // will be (now) rendered in body in IE } }

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups