Popup Window Detection and Close Button Activation

A

andrewkooi

Greetings,

I do not know whether such code exist but no harm asking:

Is it possible for me to make visible a close button if the active
window is a popup window or a new window (other than the main window)?

What I mean is this:

If the present window is the main window, then the close button should
not be visible on the page. Otherwise, the close button should be made
visible and active (i.e. can be clicked to close the window).

Any help is much appreciated.
 
R

rf

andrewkooi wrote
Is it possible for me to make visible a close button if the active
window is a popup window or a new window (other than the main window)?

All windows have a "close" button anyway. That X that the top right.
 
Z

ZER0

Is it possible for me to make visible a close button if the active
window is a popup window or a new window (other than the main window)?

Check opener property of the current window.

for example:

<script type="text/javascript">
window.onload=function(){
if (window.opener)
document.getElementById("btnClose").style.visibility="visible";
}
</script>

--
ZER0://coder.gfxer.web-designer/

~ Io non soffro di pazzia, ne godo ogni minuto.
(I don't suffer from insanity, I enjoy every minute of it)

on air ~ "Ligabue - Ho Messo Via"
 
A

andrewkooi

Greetings,
<script type="text/javascript">
window.onload=function(){
if (window.opener)
document.getElementById("btnClose").style.visibility="visible";
}
</script>

This code appeared to work fine in IE6 but does not work in NS7, or
even the latest versions of Opera and Mozilla. Any ideas how to
resolve this?

Thanx.
 
Z

ZER0

This code appeared to work fine in IE6 but does not work in NS7, or
even the latest versions of Opera and Mozilla.

This code works also in gecko-based browser (my default browser is not IE
but Firefox).
Try this page, for example:

<html>
<head>
<title>Untitled</title>
<style type="text/css">
#btnClose{margin-top:8px;display:block;visibility:hidden;}
</style>
<script type="text/javascript">
window.onload=function(){
if (window.opener)
document.getElementById("btnClose").style.visibility="visible";
}
</script>
</head>

<body>

<button onclick="window.open(window.location.href)">open a popup</button>

<button id="btnClose" onclick="window.close()">you are in a
<strong>popup</strong> window.<br />Click this button to close.</button>

</body>
</html>

(tested on FF)
 
T

Thomas 'PointedEars' Lahn

andrewkooi said:
Is it possible for me to make visible a close button if the active
window is a popup window or a new window (other than the main window)?

You asked that a few hours before, and my answer is still the same.
It is inappropriate to re-post within such a short amount of time
only because no one replied to date. Especially on Google Groups
postings take time to be archived, since it is only an archive of
Usenet postings.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top