SitePoint Sponsor |
|
User Tag List
Results 1 to 9 of 9
Thread: close a page with alert/message
-
Mar 28, 2007, 15:47 #1
- Join Date
- May 2005
- Posts
- 248
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
close a page with alert/message
Hi all,
Before the user can close a page, I would like to have a message come up that asks if this is really what they want to do. the page needs to stay open.
I got this, edited, from msdn
function closeIt()
{
event.returnValue = "";
}
<body onbeforeunload="closeIt()" >
It works just fine, too well. I get the message when the user refreshes the page, something I do not want.
Any thoughts?
Also with the above, I don't like the alert message and would like to have it read differently. Suggestions on this...
Many thanks
-
Mar 28, 2007, 17:05 #2
- Join Date
- Apr 2006
- Posts
- 802
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Nobody likes an alert popping up when they are trying to navagate away from a webpage.
-
Mar 28, 2007, 17:55 #3
- Join Date
- May 2005
- Posts
- 248
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi,
maybe not the right way to have done it, but the opening page has data on it to which other pages refer. I need to keep that initial page open so that the user can transfer data from the secondary page to the opening page.
any ideas?
thanks
-
Mar 28, 2007, 18:20 #4
- Join Date
- Apr 2006
- Posts
- 802
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Webpages are transient- Generally we save data on the server, in files or databases, uploaded from our pages.
You can pass a couple kbs of data between pages in a cookie, or a hundred characters or so on the url, but how much data can you use that doesn't belong on the server, where any page you allow can access it?
-
Mar 28, 2007, 20:33 #5
- Join Date
- May 2005
- Posts
- 248
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi
yes, I agree, pages are transient
and for among the various reasons listed above, this is what I'd like to do. The data does eventually end up on the server.
so, all other issues aside... what is possible?
thanks
-
Mar 28, 2007, 23:27 #6
- Join Date
- Jan 2004
- Location
- Los Angeles
- Posts
- 15
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi
yes, I agree, pages are transient
and for among the various reasons listed above, this is what I'd like to do. The data does eventually end up on the server.
so, all other issues aside... what is possible?
thanks
be a man/woman and tell the lamebrain idiots who need this feature that they suck at using a computer.
-
Mar 28, 2007, 23:55 #7
- Join Date
- Jan 2004
- Location
- Los Angeles
- Posts
- 15
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ha ha...
What is this?
this type of feature is needed for moronic asses who do not back up their own work and every time I need to do my work, I have to click an idiot button to post. not funny at all.
-
Mar 29, 2007, 03:29 #8
- Join Date
- Sep 2005
- Location
- Sydney, NSW, Australia
- Posts
- 16,875
- Mentioned
- 25 Post(s)
- Tagged
- 1 Thread(s)
You can use the proprietary onbeforeunload event handler to popup a confirm message in those browsers that support it but the only standard event that runs when a page is being unloaded is the onunload handler that doesn't run until after it is too late for them to change their minds.
window.onbeforeunload = function() {return confirm('Ready to leave?');};
window.onunload = function() {alert('bad luck if you forgot to backup');};Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">
-
Mar 30, 2007, 07:52 #9
- Join Date
- May 2005
- Posts
- 248
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hello
I do certainly understand all the user problems
thank you felgall for your kind(er) answer
I'll give it a try
Bookmarks