Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8777479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:17:18+00:00 2026-06-13T19:17:18+00:00

I wanted to show different divs as popup for different images on same page.

  • 0

I wanted to show different divs as popup for different images on same page.
Bellow is my code.
Script

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"/>
<script>

function showdialog(linkName, linkClass) {
    //select all the a tag
    $(linkName).click(function (e) {
        //Cancel the link behavior
        e.preventDefault();
        //Get the A tag
        var id = $(this).attr('href');

        //Get the screen height and width
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();

        //Set heigth and width to mask to fill up the whole screen
        $('#mask').css({ 'width': maskWidth, 'height': maskHeight });

        //transition effect     
        $('#mask').fadeIn(1000);
        $('#mask').fadeTo("slow", 0.8);

        //Get the window height and width
        var winH = $(window).height();
        var winW = $(window).width();

        //Set the popup window to center
        $(id).css('top', winH / 2 - $(id).height() / 2);
        $(id).css('left', winW / 2 - $(id).width() / 2);

        //transition effect
        $(id).fadeIn(2000);

    });

    //if close button is clicked
    $('.' + linkClass + ' .close').click(function (e) {
        //Cancel the link behaviors
        e.preventDefault();

        $('#mask').hide();
        $('.' + linkClass).hide();
    });

    $(window).resize(function () {

        var box = $('.' + linkClass);

        //Get the screen height and width
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();

        //Set height and width to mask to fill up the whole screen
        $('#mask').css({ 'width': maskWidth, 'height': maskHeight });

        //Get the window height and width
        var winH = $(window).height();
        var winW = $(window).width();

        //Set the popup window to center
        box.css('top', winH / 2 - box.height() / 2);
        box.css('left', winW / 2 - box.width() / 2);

    });

}

  </script>

Style

        <style>
    #mask {
      position:absolute;
      left:0;
      top:0;
      z-index:9000;
      background-color:#ffffff;
      display:none;
    }

    .appDevClass,.productEngClass,.erpServClass,.testingClass,.portalMobClass,.legacyModClass {
      position:fixed;
      left:0;
      top:-100px;
      width:700px;
      height:auto;
      display:none;
      z-index:9999;
      padding:20px;
      box-shadow: 0 0 50px 10px #006357;
      border-radius: 12px;
    }

    #appDevLink,#productEngLink,#erpServLink,#testingLink,#portalMobLink,#legacyModLink {
      width:700px; 
      height:auto;
      padding:10px;
      background-color:#ffffff;
    }

    </style>

HTML

      <div>
           <div> <img src="servicePort.png" style="position:relative;left:260px;padding-bottom:20px;"/>
           </div>
           <div >
         <a href="#appDevLink" id="appDevLinkId" name="appDev" style="position:relative;left:370px;height:100%;">   <img  onclick="javascript:showdialog('#appDevLinkId','appDevClass')" src="appDev.png" id="appDevImg"/></a>
            </div>
            <div>
         <a href="#productEngLink" id="productEngLinkId" name="productEng" style="position:relative;left:150px; ">   <img onclick="javascript:showdialog('#productEngLinkId','productEngClass')" src="productEng.png" id="productEngImg"/></a>
         <a href="#erpServLink" id="erpServLinkId" name="erpServ" style="position:relative;left:370px;">   <img onclick="javascript:showdialog('#erpServLinkId','erpServClass')" src="erpServ.png" id="erpServImg"/></a>
            </div>
            <div>
         <a href="#testingLink" id="testingLinkId" name="testing" style="position:relative;left:150px;">   <img onclick="javascript:showdialog('#testingLinkId','testingClass')" src="testing.png" id="testingImg"/></a>
         <a href="#portalMobLink" id="portalMobLinkId" name="portalMob" style="position:relative;left:370px;">   <img onclick="javascript:showdialog('#portalMobLinkId','portalMobClass')" src="portalMob.png"  id="portalMobImg"/></a>
            </div>
            <div>
         <a href="#legacyModLink" id="legacyModLinkId" name="legacyMod"  style="position:relative;left:370px;">   <img onclick="javascript:showdialog('#legacyModLinkId','legacyModClass')" src="legacyMod.png" id="legacyModImg"/></a>
            </div>
            <div>
            <img src="bottomline.png" style="position:relative;left:70px;padding-top:10px;"/>
            </div>
        </div> 

                <div  id="appDevLink" class="appDevClass">
            <a href="#"class="close" style="float:right;background-color:black;padding:3px;color:white;"/>Close </a>
            <h3>abc </h3> 
            <p>
                some ocntent here 
            </p>
        </div>

            <div id="productEngLink" class="productEngClass">
             <a href="#"class="close" style="float:right;background-color:black;padding:3px;color:white;"/>Close </a>
             <h3>abc </h3> 
            <p>
                some ocntent here 
            </p>
        </div>

            <div id="erpServLink" class="erpServClass">
             <a href="#"class="close" style="float:right;background-color:black;padding:3px;color:white;"/>Close </a>
             <h3>abc </h3> 
            <p>
                some ocntent here 
            </p>
        </div>

            <div id="testingLink" class="testingClass">
             <a href="#"class="close" style="float:right;background-color:black;padding:3px;color:white;"/>Close </a>
             <h3>abc </h3> 
            <p>
                some ocntent here 
            </p>
        </div>

            <div id="portalMobLink" class="portalMobClass">
             <a href="#"class="close" style="float:right;background-color:black;padding:3px;color:white;"/>Close </a>

            <h3>abc </h3> 
            <p>
                some ocntent here 
            </p>
        </div>

            <div id="legacyModLink" class="legacyModClass">
             <a href="#"class="close" style="float:right;background-color:black;padding:3px;color:white;"/>Close </a>
            <h3>abc </h3> 
            <p>
                some ocntent here 
            </p>
        </div>

The problem is that it opens same div as popup for multiple time.
i.e. when i click on image for time then div opens one time .
if again i click on same image then div opens 2 times & this continues.

I dont know what problem is there with this script.
Can any one help me with this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:17:20+00:00Added an answer on June 13, 2026 at 7:17 pm

    I solved it.
    Just added bellow code at the end of click function

    $(linkName).unbind('click');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running this code and it show the same time but i wanted different
Firstly apologises for the length of code but I wanted to show it all.
i wanted to show my images in a similar way as we get to
I'm using a php script to randomly show images. I've duplicated this script three
I have a modal popup which has different divs for different messages, now i
with the holiday (anouka and Christmas) i wanted to show different version of my
I wanted to show two different Navigation flows for the user when the App
So I'm making this small webstore with simplecartjs. I wanted to show a different
I wanted to show problem with this video. Please watch... I've 2 pages. Second
I wanted to show a vertical drop-down menu on click on a div. Suppose

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.