England Forum - UK Forum
 

Go Back   England Forum - UK Forum > Computers and Technology > Developers Forum > Javascript forum

 

 


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-02-2008
Peon
 
Join Date: Aug 2008
Posts: 1
Default Javascript 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:

<!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').styl e.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').styl e.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').styl e.display = 'block' " >PopUp 3</a></div>

<div id='PopUp_x_3' class="popupbox_box">
And the same here.
</div>

</body>
</html>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links

  #2 (permalink)  
Old 08-02-2008
Peon
 
Join Date: Aug 2008
Posts: 3
Default

From your code it is hard to tell for sure, but I believe you are not actually talking about popup windows, but you are manipulating the DOM to display a particular div when a link is clicked on by changing it's style to display = "block", is how I am reading it.
As doing what you want would result in an extremely long statement in each of the onclick events, because you would also need to turn the other div's "off", it is better to do it with a javascript function in a script in the head of the document and turn each div on or off by changing the value of variables to be used by the function with arguments in the call to the function from the onclick events. See in my example how: on = "block"; and: off = "none"; The function will go through the 3 div's and turn each one on or off depending on what you tell it in the onclick events arguments, as each div's display property has been assigned a variable value. The variables a,b & c receive their values from the arguments in the onclick calls to the function here.
Try this out:

<!DOCTYPE -remember to use one of these
<html>
<head>
<title>Show and tell</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>
<script type="text/javascript">
<!--
var a;
var b;
var c;
var on = "block";
var off = "none";
function showNtell()
{
document.getElementById ("PopUp_x_1").style.display = a;
document.getElementById ("PopUp_x_2").style.display = b;
document.getElementById ("PopUp_x_3").style.display = c;
/*** In the three lines above, I left a space between the Id and first ( just so Yahoo would not drop the code - should take that space out ***/
}
//-->
</script>

</head>
<!--End Head-->
<body>
<div style="text-align:right;">
<a href="#" onclick="showNtell(a=on,b=off,c=off)">
PopUp 1</a>
</div>

<div id="PopUp_x_1" class="popupbox_box">
This is now the only thing that appears when PopUp 1 is clicked
</div>

<div style="text-align:right;">
<a href="#" onclick="showNtell(a=off,b=on,c=off)">
PopUp 2</a></div>

<div id="PopUp_x_2" class="popupbox_box">
And this is now the only thing that appears when PopUp 2 is clicked. See, no problem?
</div>

<div style="text-align:right;">
<a href="#" onclick="showNtell(a=off,b=off,c=on)">
PopUp 3</a></div>

<div id="PopUp_x_3" class="popupbox_box">
And this is now the only thing that appears when PopUp 3 is clicked. It's all good, oh yeah!
</div>

</body>
</html>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-02-2008
Peon
 
Join Date: Aug 2008
Posts: 1
Default

i don't think it's possible to stop overlapping from ocurring...because it opens in another browser window how can you expect communication to occur between the two windows? i seriously doubt it's possible
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:18 AM.


Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0 RC7
Sedo - Buy and Sell Domain Names and Websites project info: englanddebate.co.uk Statistics for project englanddebate.co.uk etracker® web controlling instead of log file analysis

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181