SledgeHammer wrote:
Hi group,
Little question that bugs me ....
I have a page (window) with frames.
Topframe + MainFrame = page
I want to close the whole window, but don't know how
Can somebody help me with this one ?
Thx
Berre
Only a window opened via javascript can be closed with javascript.
Assuming this multi-frame page is a requested popup, then call the
close() method on the window object reference of that popup. E.g.:
<script type="text/javascript">
<!--
var WindowObjectRef erenceOfRequest edPopup ;
function OpenRequestedPo pup(strUrl, strTarget)
{
var windowWidth, windowHeight, windowLeft, windowTop;
if(typeof window.screenX == "number" && typeof window.innerWid th ==
"number")
{
windowWidth = window.innerWid th * .68;
windowHeight = window.innerHei ght * .68;
windowLeft = window.screenX + window.innerWid th * .16;
windowTop = window.screenY + window.innerHei ght * .16;
}
else if(typeof window.screenTo p == "number" && typeof
document.docume ntElement.offse tHeight == "number")
{
windowWidth = document.docume ntElement.offse tWidth * .68;
windowHeight = document.docume ntElement.offse tHeight * .68;
windowLeft = window.screenLe ft + document.docume ntElement.offse tWidth *
..16;
windowTop = window.screenTo p - 50;
}
else
{
windowWidth = 500;
windowHeight = 250;
windowLeft = 60;
windowTop = 40;
};
/* The above code is just to define reasonable sizes and initial
positions to the popup to be. */
if (WindowObjectRe ferenceOfReques tedPopup == null ||
WindowObjectRef erenceOfRequest edPopup.closed)
{
WindowObjectRef erenceOfRequest edPopup = window.open(str Url, strTarget,
"top=" + windowTop + ",left=" + windowLeft + ",width=" + windowWidth +
",height=" + windowHeight + ",menubar,resiz able,scrollbars ,status");
}
else
{
WindowObjectRef erenceOfRequest edPopup.focus() ;
};
/*
The above 9 lines of code creates the popup; if the popup is already
opened, then it is only brought on top. This feature is possible only if
the user allows it in Mozilla-based browsers via the setting
Edit/Preferences.../category:Advanc ed/Scripts & Plugins/Allow webpages
to:/Raise or lower windows
*/
}
function CloseRequestedP opup()
{
if(WindowObject ReferenceOfRequ estedPopup != null &&
!WindowObjectRe ferenceOfReques tedPopup.closed )
{
WindowObjectRef erenceOfRequest edPopup.close() ;
};
}
-->
</script>
DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/