Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Close window with frames in it

Reply
Thread Tools

Close window with frames in it

 
 
SledgeHammer
Guest
Posts: n/a
 
      07-08-2003
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


 
Reply With Quote
 
 
 
 
DU
Guest
Posts: n/a
 
      07-09-2003
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 WindowObjectReferenceOfRequestedPopup ;

function OpenRequestedPopup(strUrl, strTarget)
{
var windowWidth, windowHeight, windowLeft, windowTop;

if(typeof window.screenX == "number" && typeof window.innerWidth ==
"number")
{
windowWidth = window.innerWidth * .68;
windowHeight = window.innerHeight * .68;
windowLeft = window.screenX + window.innerWidth * .16;
windowTop = window.screenY + window.innerHeight * .16;
}
else if(typeof window.screenTop == "number" && typeof
document.documentElement.offsetHeight == "number")
{
windowWidth = document.documentElement.offsetWidth * .68;
windowHeight = document.documentElement.offsetHeight * .68;
windowLeft = window.screenLeft + document.documentElement.offsetWidth *
..16;
windowTop = window.screenTop - 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 (WindowObjectReferenceOfRequestedPopup == null ||
WindowObjectReferenceOfRequestedPopup.closed)
{
WindowObjectReferenceOfRequestedPopup = window.open(strUrl, strTarget,
"top=" + windowTop + ",left=" + windowLeft + ",width=" + windowWidth +
",height=" + windowHeight + ",menubar,resizable,scrollbars,status");
}
else
{
WindowObjectReferenceOfRequestedPopup.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:Advanced/Scripts & Plugins/Allow webpages
to:/Raise or lower windows
*/
}

function CloseRequestedPopup()
{
if(WindowObjectReferenceOfRequestedPopup != null &&
!WindowObjectReferenceOfRequestedPopup.closed)
{
WindowObjectReferenceOfRequestedPopup.close();
};
}

-->
</script>

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to close a TCP socket? (TCPSocket#close doesn't close it) Iñaki Baz Castillo Ruby 7 01-12-2010 01:32 PM
close all child windows when close the main window jrefactors@hotmail.com HTML 6 08-07-2008 09:10 AM
close current window using window.close() Shang Wenbin Javascript 10 09-02-2005 12:16 AM
Self.close() window without the dialog close?Yes/NO Walter Beierdonck Javascript 1 04-30-2004 02:48 PM
close all the frames to open a page in the current window Matt HTML 2 10-25-2003 11:36 AM



Advertisments
 



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