Grabbing local hostname and creating link with images Javascript

I am trying to create an image link based on the location of the server it is hosted on. If the server is server1. I want the image to be linked to http://server1/dod" I'm trying to get two images with this shot. However, nothing is loading. I am missing a piece and I don't know where. I'm also hosting this on an IIS server.

<!DOCTYPE html>
<html>
     <body>
          <div>
             <p id="Images"></p>
          </div>
      &lt;script&gt;
           var local = location.hostname;

//SP Edit, save a reference to the images node
var Images = document.getElementById(“Images”);

           var dodlink = document.createElement(a);
           dodlink.href = "http://" + local + "/DoD/";

           var dodimg = document.createElement("img");

//SP Edit dodimg.src =“DOD.png”;
//SP Edit dodimg.width = 256;
//SP Edit dodimg.height = 256;
dodimg.setAttribute(“src”, “DOD.png”);
dodimg.setAttribute(“width”, “256px”);
dodimg.setAttribute(“height”, “256px”);
dodlink.appendChild(dodimg);

//SP Edit document.getElementByID(“Images”).innerHTML = dodimg;
Images.appendChild(dodimg);

           var derlink = document.createElement(a);

//SP Edit derlink.href = “http://” + local + “/DER/”;
deflink.setAttribute(“href”, “http://” + local + “/DER/”);

           var derimg = document.createElement("img");

//SP Edit derimg.src =“DER.png”;
//SP Edit derimg.width = 256;
//SP Edit derimg.height = 256;
derimg.setAttribute(“src”, “DER.png”);
derimg.setAttribute(“width”, “256px”);
derimg.setAttribute(“height”, “256px”);
deflink.appendChild(derimg);

// Images.appendChild(deflink);

#html #javascript

3 Likes2.95 GEEK