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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.