Jump to content

Javascript popup window changes display style for different images


james909

Recommended Posts

 

Here is my Code, It is a popup to change an image main window, I am trying to get the image to display if image 2,3 or 4 are selected, and no image to display is image 1 is selected. It all works except getting the If statement to check whether image 1 is selected or not:



<!DOCTYPE html>
<html lang="en">
<head>


<meta charset="utf-8">


<title>Select an Armor</title>


<link rel="stylesheet"  href="selectwindow.css">


<script>
(function() {
   'use strict';


function removeWindow(){


if(window.name='wxyz'){
  var pic=document.getElementById('thumbs').getElementsByTagName('img');
  var c=pic.length;


while(--c>-1) {
pic[c].onclick=function(){
   window.opener.document.getElementById('windowc').src=this.src.replace('-thumb','');
   window.opener.document.getElementById('windowc').style.display="inline"; 
   if(pic.src=="pics/Image1.png") { window.opener.document.getElementById('a1windowchange').style.display="none"; }
   window.close();
  }
 }


  var txt=document.createTextNode('close this window'); 
  var cl=document.createElement('h2');
      cl.setAttribute('id','wincl');
      cl.appendChild(txt);


  document.body.appendChild(cl);


document.getElementById('wincl').onclick=function(){
   window.close();
   }
  }
 }
   window.addEventListener?
   window.addEventListener('load',removeWindow,false):
   window.attachEvent('onload',removeWindow);
   function closeme()
    {  
        window.close();
    }
    window.onblur=closeme;
})();
</script>


</head>
<body>


<ul id="thumbs">
 <li><img src="pics/Image1.png" alt=""></li>
 <li><img src="pics/Image2.png" alt=""></li>
 <li><img src="pics/Image3.png" alt=""></li>
 <li><img src="pics/Image4.png" alt=""></li>
</ul>


</body>


What is the correct way to code: if(pic.src=="pics/Image1.png")

 

To check whether pics/Image1.png has been selected or not?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.