 |
09-16-2002, 08:08 PM
|
closing out a new window
|
Posts: 8
Location: Poughkeepsie, NY
|
Hello,
Does anyone know how to disable the ability to close out a pop up window using the "x" in the upper right hand corner of the window? I would like to force people to close the window by clicking on a "close" button that I provide, because I then execute some code which will not get executed if the window is closed by "x-ing out" using the "x" in the upper right hand corner of the window. Thanks in advance for any help!
Bob
|
|
|
|
09-16-2002, 09:04 PM
|
|
Posts: 1,733
Name: Josh
Location: Miami, FL
|
simple, make the window fullscreen like most other sites do when they force you to view an ad. The only way out of it is ALT-Tab then right click and close, Ctrl+Alt+Del which will restore their explorer, or they can choose the close button you provide if you provide one.
Here is teh code:
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function fullScreen(URL {
window.open(URL, '', 'fullscreen=yes, scrollbars=auto');
}
// End -->
</script>
</HEAD>
<BODY>
<a href="javascript:void(0);" onClick="fullScreen('YOUR WEBSITE ADDRESS GOES HERE');">Click here to find out more information (opens full screen window)</a>
|
|
|
|
09-16-2002, 10:04 PM
|
|
Posts: 8
Location: Poughkeepsie, NY
|
Ghettocars,
Thanks for the quick reply. Your suggestion works. I was hoping to still be able to use a smaller window rather than opening in fullscreen. I was hoping there was just a way to disable the "x" on the window I open. I thought I saw that done somewhere, but maybe not. Thanks again.
Bob
|
|
|
|
09-17-2002, 01:38 AM
|
|
Posts: 104
Location: San Diego, Ca
|
I know you probly don't wanna hear it... but a lot of people really can't stand those boxes that pop up and won't go away without clicking somewheres on it... I personally hate them with a passion.. and there are programs designed to stop them.. that should be a hint 
__________________
Porch Monkey. And that's the truth.
|
|
|
|
09-17-2002, 07:12 AM
|
|
Posts: 8
Location: Poughkeepsie, NY
|
iqchicken,
Thanks for the reply. I agree - I also hate those pop up windows. So let me explain a little further what it is I am doing. I maintain a web site for a high school drama organization. I've written my own chat software for them to use while on the site. The chat facitlity opens up in a separate window, and it keeps track of who is logged on, and how many users are logged on. I provide a "logout" button for them to log out of chat. When they hit that button, I remove their name from the list, and decrement the number of users logged on. If they just "x" out of the window instead, this software does not get executed, so it still shows them as logged in, when they are not. I'd just like to force them to use the logout button when logging out of the chat facility. Thanks again. 
|
|
|
|
09-17-2002, 05:26 PM
|
|
Posts: 1,314
Location: Glasgow, UK
|
Here's an idea. What about if you opened the page as a layer or div in DHTML, like those floating ads that come onto your page.
If you really want to try something clever, theres a system like you are talking about here:
http://www.clyde1.com
I bet its complex code though 
|
|
|
|
09-17-2002, 06:04 PM
|
|
Posts: 373
Location: Ames, IA
|
I would use chromeless windows and then just edit the code so there is no little x in the top. It will take some work but I think it can be done.
Chromeless: http://www.dynamicdrive.com/dynamici...chromeless.htm
-dk
__________________
Did I help you? If so, be nice and throw me some TP
|
|
|
|
09-17-2002, 08:57 PM
|
|
Posts: 8
Location: Poughkeepsie, NY
|
dk01,
Thanks for the idea. Very interesting, and would probably work, except the chromeless effect only works in IE. With NS you get a normal window. Since I have users of both browsers, this would not totally solve the problem.
I can't believe this is such a hard thing to do! Why don't they just provide a parameter on the window.open such as "disableclose=yes"!
Thanks again,
Bob
|
|
|
|
09-18-2002, 07:39 AM
|
|
Posts: 1,733
Name: Josh
Location: Miami, FL
|
well, the floating popup idea is a very good one, The window size is customizable and you can make it pop up anywhere, it floats around and it has no 'X'.
ill try and find out the code for you.
|
|
|
|
09-18-2002, 04:22 PM
|
|
Posts: 373
Location: Ames, IA
|
ahhhh I have an idea! If you do:
<head>
<script language="javascript">
username = "<?php echo($username); ?>";
page = "logoutpage.php?username=" + username;
logwin = window.open(page, 'logoutwin');
</script>
</head>
<body onUnload="logout();">
Ok so I just throwing out code here and don't know if it would actually work but I know that you could do something using the onUnload attribute to the body tag (it specifies a function to be run when the window is closed or the user leaves the page).
Hope this helps! I shoulda thought of it before!
-dk
__________________
Did I help you? If so, be nice and throw me some TP
|
|
|
|
09-18-2002, 05:01 PM
|
|
Posts: 1,314
Location: Glasgow, UK
|
Just an idea, couldn't you do something where instead of the user having to log out when they leave, you could re-log-them-in if they stay?
For example, assuming you are using some form of HTML for your chat room, you will have a page which is refreshed regularly by the browser.
You could set your backend software to automatically log out anyone who hasn't refreshed the page for x seconds, and then set the standard refresh rate to once every 1/2x (for example). Then, if someone left, their browser would not request the new page, they would not be 're-logged-in' and they would effectively have logged out of the chat.
|
|
|
|
09-18-2002, 05:51 PM
|
|
Posts: 91
Location: Utah
|
There is a way to script it in javascript so that you can set the size of the window you're opening and make it so there is no toolbar or 'x' in the top right. Then you can make it so that they have to click on your button (they could still 'alt + f4' the window closed)
Right off i don't know the code though.
|
|
|
|
09-19-2002, 07:53 PM
|
|
Posts: 8
Location: Poughkeepsie, NY
|
Zoram/David/Dk01,
First of all, THANK YOU for all of your help with this!
Zoram - that's exactly what I want to do, but I've been trying to find a way to do that for weeks, and I can not find any way to use javascript to open a window that does not have an "x" in the upper right hand corner. If you can find a way, PLEASE post it here! Thanks.
David - I'm not sure if I follow your suggestion. When someone makes an entry, I execute perl code that reads the html file, updates it, and writes it back out. The page automatically refreshes every 3 seconds so everyone sees all the updates. I don't know how to tell when or if an individual requests the page.
Dk - Good idea! I already thought of the onUnload idea, and I've tried to get it to work. I've been able to execute a javascript function on unload, but I can not figure out how to execute the perl script that does the cleanup (removes the person from the list of users and decrements the total number of users logged on). I tried putting a form with the action= pointing to my perl script, then saying something like document.xxx.submit(); in my javascript that gets executed on the unload, but I can not get it to work. If you have any more thoughts on how to do this, I'd appreciate it.
Again, thanks to all of you!
Bob
|
|
|
|
09-19-2002, 10:56 PM
|
|
Posts: 153
|
Pop ups that are hard to close are extremely annoying. I wouldnt suggest putting them on your site. You wont get many return visitors.
|
|
|
|
09-20-2002, 07:13 AM
|
|
Posts: 8
Location: Poughkeepsie, NY
|
Moe,
I agree with your sentiments about pop-ups, but I don't think you read the entire string here before you responded. This is not an annoying pop-up that I am talking about. It is a function that I am providing, that the user would enter because he WANTS to. It is chat software I wrote for users of the site to chat with each other. It opens in a speparate window, so they can still do other work while they are chatting, if desired. The reason I want to force them to logout by clicking on the logout button I provide, instead of the "x" is that I execute some clean up software upon exiting that would not get done otherwise. Thanks.
Bob
|
|
|
|
09-20-2002, 02:04 PM
|
|
Posts: 8
Location: Poughkeepsie, NY
|
dk,
OK. I got the code to work using the onUnload event handler! Now if you click on the "x" I execute all the clean up code and everything is fine. The problem then became, if you click on thet "logout" button, the code got executed twice! So I was decrementing the number of users by 2 instead of 1. I tried to figure out how to tell the difference as to whether someone hit the "x" or the "logout" button, then decided, the heck with it - I just eliminated the "logout" button. Now to exit chat, you just click on the "x" and everything is fine (which is what everyone seemed to want to do anyway!).
Thanks again to everyone for all their help/suggestions!
Bob
|
|
|
|
09-20-2002, 02:08 PM
|
|
Posts: 8
Location: Poughkeepsie, NY
|
dk,
OK. I got the code to work using the onUnload event handler! Now if you click on the "x" I
execute all the clean up code and everything is fine. The problem then became, if you click on
the "logout" button, the code got executed twice! So I was decrementing the number of users by 2 instead of 1. I tried to figure out how to tell the difference as to whether someone hit the
"x" or the "logout" button, then decided, the
heck with it - I just eliminated the "logout" button.
Now to exit chat, you just click on the "x" and everything is fine (which is what everyone
seemed to want to do anyway!).
Thanks again to everyone for all their help/suggestions!
Bob
|
|
|
|
09-20-2002, 04:54 PM
|
|
Posts: 1,733
Name: Josh
Location: Miami, FL
|
hmmm double post?
well anyways, glad you already fixed the problem Imma check the chat out later on and see how it is.
-Josh 
|
|
|
|
09-20-2002, 08:06 PM
|
|
Posts: 373
Location: Ames, IA
|
Ah a solution to that is to put make a variable called logout and use that to see if the logout button was pushed:
<head>
<script>
var logout = false;
function DoLogout()
{
if(!logout)
{
alert("You clicked the x!");
}
else
{
alert("you clicked the botton!");
}
}
</script>
</head>
<body onunload="logout=true;DoLogout();">
I dunno. Your way works perfectly fine so why change it right?. I just like brainstorming!  Glad you got it finally!
-dk
__________________
Did I help you? If so, be nice and throw me some TP
|
|
|
|
|
« Reply to closing out a new window
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|