473,396 Members | 1,913 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Javascript close popup

Hi guys,

Just a quickie here that i hope someone can help me with. Basically i
want stop the user from closing the popup window using the small x
button in the top right hand corner. Im aware that i cant disable this
so i thought is it possible to do a check to see if a hidden text on
the main form has a value. E.g. if we close the popup correctly then
text box on the main form will say true. If we close the text box
using the x in the right hand corner the text box will say false or
just be empty and then make the popup reapppear.

Is this possible and if so would anyone have any example of how i
would go about this because im pretty useless and new to javascript.

thanks in advance

CG
Jul 23 '05 #1
4 5641
Colin Graham wrote on 28 apr 2005 in comp.lang.javascript:
Just a quickie here that i hope someone can help me with. Basically i
want stop the user from closing the popup window using the small x
button in the top right hand corner. Im aware that i cant disable this
so i thought is it possible to do a check to see if a hidden text on
the main form has a value. E.g. if we close the popup correctly then
text box on the main form will say true. If we close the text box
using the x in the right hand corner the text box will say false or
just be empty and then make the popup reapppear.

Is this possible and if so would anyone have any example of how i
would go about this because im pretty useless and new to javascript.


If you are pretty useless and new to javascript,
how do you know this is just a quickie, Colin?

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #2
You could add a window.open in the OnBeforeUnload event of the body to
open the window. Pretty annoying though.
-Vick

Jul 23 '05 #3
"Colin Graham" <cs********@hotmail.com> wrote in message
news:ee**************************@posting.google.c om...
Hi guys,

Just a quickie here that i hope someone can help me with. Basically i
want stop the user from closing the popup window using the small x
button in the top right hand corner. Im aware that i cant disable this
so i thought is it possible to do a check to see if a hidden text on
the main form has a value. E.g. if we close the popup correctly then
text box on the main form will say true. If we close the text box
using the x in the right hand corner the text box will say false or
just be empty and then make the popup reapppear.


Do the reverse. Have the parent test if the child window is still open
using setInterval(). If the parent detects the child has closed it
re-spawns the window. The way to stop the cycle is have a "Close" button
on the child that properly terminates the timer in the parent before
closing the window.

<script type="text/javascript">
window.newWindowHtml = [
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">',
'<html>',
'<head>',
'<title>Test</title>',
'</head>',
'<body onload="opener.startTimer();">',
'<a href="#" onclick="opener.stopTimer();window.close();return
false;">Close</a>',
'</body>',
'</html>'
].join('\n');
function openWindow()
{
window.w = window.open('javascript:opener.newWindowHtml');
}
function startTimer()
{
window.timer = setInterval(testWindow, 500);
}
function stopTimer()
{
if (window.timer)
{
clearInterval(window.timer);
}
}
function testWindow()
{
if (!w || w.closed)
{
openWindow();
}
testWindow.toString = function()
{
return 'testWindow();';
}
}

openWindow();
</script>

REALLY annoying, but it seems to meet your requirements.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Pretty annoying, but it would work.
Jul 23 '05 #4
Stephen Vick wrote:
You could add a window.open in the OnBeforeUnload event
of the body to open the window. Pretty annoying though.


And IE only, fortunately.
PointedEars
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Arthur Connor | last post by:
Below you will find the first lines of my HTML page. Why doesn't popup a dialog window ? I click the Html page which is on my hard disc. A IE 5.5 browser window opens but not a dialog window...
2
by: TeknoCat | last post by:
Hey everyone, I may be repeating myself here, but if someone sent a reply then I missed it, and I can't get Outlook Express to download any messages more than 2 days old. Anyway, I'm having a...
3
by: John Bokma | last post by:
I have two windows in a frame. I want to be able that each can open a pop up window and that the handle to that window can be stored somewhere, so that each can talk to the pop up. is it...
4
by: ...D. | last post by:
OK. I am halfway decent with HTML. Now I want to try javascript for some things that HTML cannot do. I have looked over a tutorial & all. What I want to do is create a button, that when...
14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
12
by: Mark Fox | last post by:
Hello, I am attempting to do something very simple. I have a page MainPage.aspx and a popup window Popup.aspx. When users click on the linkbutton in the popup window I am looking to do some...
9
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work...
4
by: E | last post by:
I am having trouble with setTimeout working on a second call to the setTimeout function from a second page which is an html page. Here is the scenario. I have a web page and onload it calls a...
2
by: Jeff | last post by:
I'm hoping that someone can help me. I know little javascript and only need a very small amount in an asp.net application. I have most of it working with one problem. I'm attempting to open a modal...
16
by: Eric | last post by:
I have a user of a web application written in Java/JSP that is unable to login to the site simply because certain links on the page do not run when they are clicked. Other popups using Javascript...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.