473,549 Members | 2,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5655
Colin Graham wrote on 28 apr 2005 in comp.lang.javas cript:
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********@hot mail.com> wrote in message
news:ee******** *************** ***@posting.goo gle.com...
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.newWindo wHtml = [
'<!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();wi ndow.close();re turn
false;">Close</a>',
'</body>',
'</html>'
].join('\n');
function openWindow()
{
window.w = window.open('ja vascript:opener .newWindowHtml' );
}
function startTimer()
{
window.timer = setInterval(tes tWindow, 500);
}
function stopTimer()
{
if (window.timer)
{
clearInterval(w indow.timer);
}
}
function testWindow()
{
if (!w || w.closed)
{
openWindow();
}
testWindow.toSt ring = function()
{
return 'testWindow();' ;
}
}

openWindow();
</script>

REALLY annoying, but it seems to meet your requirements.

--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript 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
3592
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 inside. <HTML> <HEAD> <TITLE>Test page</TITLE> <script LANGUAGE="JavaScript"> <!--
2
2185
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 problem with some new pages I am creating for the Web site at www.weaverdevore.ca and I am wondering if anyone here might be able to help. Here is...
3
3535
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 possible that window 1 in a frameset calls a function in window 2, ie. something like: window 1: ....
4
2196
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 pressed, closes the window it is in, and launches a URL. The window the button is in is actually just a sub-page of the main website page, launched with...
14
5430
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 that works well as an html page. It brings up a modal popup window that I have been trying to work out for days now and this was the closest I...
12
1904
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 server side processing in Popup.aspx, then have the popup window close, and have the MainPage.aspx do a postback to the server. But I am having...
9
4894
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 fine from a link. The button does bring up the popup window, but when I press the links on the page, it doesn't return or close the window. ...
4
5215
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 javascript function which calls setTimeout and will process a second javascript function "Warn" just before the session expires. The Warn...
2
2094
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 dialog box from a parent window. The dialog box opens fine with the code below associated with the parent. In the child window, I have a button...
16
2306
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 on the same page work correctly. It appears to be isolated to 1-2 machines in a particular network. I cannot verify whether these machines have...
0
7520
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7450
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7957
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7470
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7809
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3500
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1941
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.