skeatt
09-01-2002, 10:42 AM
I been playing with some code to open PopUps of different sizes for different PortFolio images.
If I used the window "name" when opening new images it would load into the existing PopUp and ignore any new window sizes.
I found the only way to do this was to close the current PopUp (if it was open) and re-open a new window with a new size.
Unfortunately this could be annoying for a user if they have to keep moving it aside to "their" prefered location, so is there a way to test for the PopUp's current screen location so that you can reuse the coordinates for the new window?
Here is some of the code for setting the first window up and testing if one is open. Try moving the PopUp and click links to see what I mean. (A test1.html and test2.html file is also used,also only tested in IE)
<html><head><title>Steven Eatt's PopUp</title>
<script>
<!-- hide me
var winPopUp = null;
function reloadWin(myUrl,popName,W,H,scroll) {
if (winPopUp && !winPopUp.closed) {
winPopUp.close()
PopUp(myUrl,popName,W,H,scroll) }
else {
PopUp(myUrl,popName,W,H,scroll) }}
function PopUp(myUrl,popName,W,H,scroll){
var positionX = (screen.width) ? (screen.width - W)/2 : 0; //Left
var positionY = (screen.height) ? (screen.height - H)/2 : 0; //Top
var features="width="+W+",height="+H+",left="+positionX+
",top="+positionY+",screenX="+positionX+",screenY="+positionY+
",scrollbars="+scroll+",toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1"
winPopUp=window.open(myUrl,popName,features); //Defined as global, Features also resizable.
winPopUp.focus() // Can exclude this when reloadWin function directly
}
// show me -->
</script>
</head>
<body>
<a href="javascript:reloadWin('test1.html','winName','300','150','0')">Window One</a>
<br><br>
<a href="javascript:reloadWin('test2.html','winName','150','300','0')">Window Two</a>
<br><br><br><br>
<a href="javascript:PopUp('test1.html','winName','300','150','0')">Window One</a>, No window test
<br><br>
<a href="javascript:PopUp('test2.html','winName','150','300','0')">Window Two</a>, No window test
</body>
</html>
Note: features go on one line. Use this for the second windows
<HTML>
<HEAD><Title>PopUp Test</title>
<h2>This is Page One</h2>
</HEAD>
</html>
If I used the window "name" when opening new images it would load into the existing PopUp and ignore any new window sizes.
I found the only way to do this was to close the current PopUp (if it was open) and re-open a new window with a new size.
Unfortunately this could be annoying for a user if they have to keep moving it aside to "their" prefered location, so is there a way to test for the PopUp's current screen location so that you can reuse the coordinates for the new window?
Here is some of the code for setting the first window up and testing if one is open. Try moving the PopUp and click links to see what I mean. (A test1.html and test2.html file is also used,also only tested in IE)
<html><head><title>Steven Eatt's PopUp</title>
<script>
<!-- hide me
var winPopUp = null;
function reloadWin(myUrl,popName,W,H,scroll) {
if (winPopUp && !winPopUp.closed) {
winPopUp.close()
PopUp(myUrl,popName,W,H,scroll) }
else {
PopUp(myUrl,popName,W,H,scroll) }}
function PopUp(myUrl,popName,W,H,scroll){
var positionX = (screen.width) ? (screen.width - W)/2 : 0; //Left
var positionY = (screen.height) ? (screen.height - H)/2 : 0; //Top
var features="width="+W+",height="+H+",left="+positionX+
",top="+positionY+",screenX="+positionX+",screenY="+positionY+
",scrollbars="+scroll+",toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1"
winPopUp=window.open(myUrl,popName,features); //Defined as global, Features also resizable.
winPopUp.focus() // Can exclude this when reloadWin function directly
}
// show me -->
</script>
</head>
<body>
<a href="javascript:reloadWin('test1.html','winName','300','150','0')">Window One</a>
<br><br>
<a href="javascript:reloadWin('test2.html','winName','150','300','0')">Window Two</a>
<br><br><br><br>
<a href="javascript:PopUp('test1.html','winName','300','150','0')">Window One</a>, No window test
<br><br>
<a href="javascript:PopUp('test2.html','winName','150','300','0')">Window Two</a>, No window test
</body>
</html>
Note: features go on one line. Use this for the second windows
<HTML>
<HEAD><Title>PopUp Test</title>
<h2>This is Page One</h2>
</HEAD>
</html>