skeatt
11-27-2002, 07:54 AM
I have a main page that opens the popUp and tracks the movement of the popup window. When you close it from the main page it stores the popUps last location so that when opened again it opens in the same position.
win = window.open( url , "newWindow" ,"left=" + scnX + ",top=" + scnY + features....."
function closePopUp(name) {
if (win && !win.closed) { //check to see if window isn't already closed
storeXY() // go to function to store coordinance
alert("X= " + scnX + " Y= " + scnY ) // debugging
win.close();
}
}
Problem: close the popUp "from" the popUp, how do you pass values back to the opener so that it knows it's last position. "scnX and scnY"
<html>
<head>
<Title>PopUp Test</title>
<h2>This is Page One</h2>
<script language="javascript">
function storeXY() { // screenLeft is IE, screenX is Netscape, subtract window borders and features, could vary slightly +/- 1 pixel.
scnX = typeof window.screenLeft != "undefined" ? window.screenLeft - 4 : window.screenX; // Borders = 4
scnY = typeof window.screenTop != "undefined" ? window.screenTop - 52 : window.screenY; // Y= No features = 23, Toolbar = 52,
}
function closeMe(name) {
alert("X= " + scnX + " Y= " + scnY ) // debugging
storeXY()
window.close();
}
function showXY() {
storeXY()
alert("X= " + scnX + " Y= " + scnY ) //debugging
}
</script>
</head>
<body onload="storeXY()" >
<a href="javascript:window.closeMe()"> 3) close this window<br><br>
<a href="javascript:window.showXY()"> 3) Show scnX / scnY value<br>
</body>
</html>
win = window.open( url , "newWindow" ,"left=" + scnX + ",top=" + scnY + features....."
function closePopUp(name) {
if (win && !win.closed) { //check to see if window isn't already closed
storeXY() // go to function to store coordinance
alert("X= " + scnX + " Y= " + scnY ) // debugging
win.close();
}
}
Problem: close the popUp "from" the popUp, how do you pass values back to the opener so that it knows it's last position. "scnX and scnY"
<html>
<head>
<Title>PopUp Test</title>
<h2>This is Page One</h2>
<script language="javascript">
function storeXY() { // screenLeft is IE, screenX is Netscape, subtract window borders and features, could vary slightly +/- 1 pixel.
scnX = typeof window.screenLeft != "undefined" ? window.screenLeft - 4 : window.screenX; // Borders = 4
scnY = typeof window.screenTop != "undefined" ? window.screenTop - 52 : window.screenY; // Y= No features = 23, Toolbar = 52,
}
function closeMe(name) {
alert("X= " + scnX + " Y= " + scnY ) // debugging
storeXY()
window.close();
}
function showXY() {
storeXY()
alert("X= " + scnX + " Y= " + scnY ) //debugging
}
</script>
</head>
<body onload="storeXY()" >
<a href="javascript:window.closeMe()"> 3) close this window<br><br>
<a href="javascript:window.showXY()"> 3) Show scnX / scnY value<br>
</body>
</html>