Results 1 to 2 of 2

Thread: Popups overlap

  1. #1
    Join Date
    Jul 2008
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Popups overlap

    I have some javascript commands which make a pop-up window appear on the other sde of the broswer. There are three pop-ups. The problem is if you click on one and then another they overlap.

    What I want is for a popup to close when another is opened.

    Any ides?

    Here is the code so far:

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    
    <title>PopUp</title>
    
    <STYLE type="text/css">
    .popupbox_box {display: none; position: absolute; left: 50px; top: 50px; border: solid #561721 1px; padding: 10px; text-align: justify; font-size: 12px; width: 400px;}
    </STYLE>
    
    <link href="scripts/styling.css" rel="stylesheet" type="text/css" />
    
    </head>
    
    <body>
    
    <div align="right">
    <a onmouseover="this.style.cursor='pointer'" onclick="document.getElementById('PopUp_x_1').style.display = 'block'" >PopUp 1</a></div>
    
    <div id="PopUp_x_1" class="popupbox_box">
    This is what appears when PopUp 1 is clicked
    </div>
    
    <div align="right">
    <a onmouseover="this.style.cursor='pointer'" onclick="document.getElementById('PopUp_x_2').style.display = 'block' " >PopUp 2</a></div>
    
    <div id='PopUp_x_2' class="popupbox_box">
    And this appears when PopUp 2 is clicked. See the problem?
    </div>
    
    
    <div align="right">
    <a onmouseover="this.style.cursor='pointer'" onclick="document.getElementById('PopUp_x_3').style.display = 'block' " >PopUp 3</a></div>
    
    <div id='PopUp_x_3' class="popupbox_box">
    And the same here.
    </div>
    
    </body>
    </html>

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Add highlighted:
    Code:
    <a onmouseover="this.style.cursor='pointer'" onclick="reset();document.getElementById('PopUp_x_1').style.display = 'block'" >
    
    <a onmouseover="this.style.cursor='pointer'" onclick="reset();document.getElementById('PopUp_x_2').style.display = 'block' " >
    
    <a onmouseover="this.style.cursor='pointer'" onclick="reset():document.getElementById('PopUp_x_3').style.display = 'block' " >
    And have this script:
    Code:
    <script type="text/javascript">
    function reset(){
    var del=['PopUp_x_1','PopUp_x_2','PopUp_x_3']; // Place all those popup box in this array
    for(var i=0;i<del.length;i++){document.getElementById(del[i]).style.display='none';}}
    </script>
    Hope that helps.
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  3. The Following User Says Thank You to rangana For This Useful Post:

    spirofantasio (08-02-2008)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •