Welcome Guest!
Please login
If you do not have an account yet on The Web Squeeze forums, please Register! It’s FREE and there are many benefits:
- Receive Fast Advice
- Learn Programming Languages
- Get Professional Website Reviews
- Quick Troubleshooting Assistance
Confirm You Would Like To Close New Thread Windows
This is a discussion on Confirm You Would Like To Close New Thread Windows, within the Feedback section. This forum and the thread "Confirm You Would Like To Close New Thread Windows" are both part of the Feedback category.
![]() ![]() |
Sep 3 2008, 05:09 PM
Post
#1
|
|
|
Master of the Universe ![]() Posts: 1,298 Joined: 15-February 08 From: London, England |
Could we have a JavaScript confirm when a new topic page is closed and something is entered into the content box. It is a rare occurrence but twice now I have accidentally closed down a thread I have been working on.
-------------------- |
|
|
Sep 3 2008, 08:21 PM
Post
#2
|
|
![]() Co-Founder ![]() Posts: 2,664 Joined: 13-February 08 From: On the forum! |
Hmmmm, I actually think I've done this a few times as well. It's super annoying, and you can never recreate that master piece again....lol. I don't know JavaScript, or even if this is possible....Luke? Do you think this is possible?
-------------------- Thanks,
Jacob |
|
|
Sep 3 2008, 08:55 PM
Post
#3
|
|
![]() Squeeze Machine ![]() Posts: 766 Joined: 13-February 08 From: Catching the squeezed drips downunder. |
CODE // Assuming jQuery is available
$(document).ready(function() { $('textarea, input').change(function() { $(window).unload(function (e) { if (confirm('Are you sure you would like to move away from this page? You changes will be lost')) return true else e.preventDefault(); } } }); // Assuming jQuery is not available var elements = document.getElementsByTagName('*'); var nm = elements.length; for (i=0; i<nm; i++) { if (elements[i].tagName == 'TEXTAREA' || elements[i].tagName == 'INPUT') { elements[i].currentChangeFunction = elements[i].onchange; elements[i].onchange = function () { window.onunload = function () { return confirm('Are you sure you would like to move away from this page? You changes will be lost'); }; this.currentChangeFunction(); }; } } -------------------- |
|
|
Sep 3 2008, 09:26 PM
Post
#4
|
|
![]() Co-Founder ![]() Posts: 2,664 Joined: 13-February 08 From: On the forum! |
Okay, I added that code....however, it does not appear to be working.
-------------------- Thanks,
Jacob |
|
|
Sep 3 2008, 09:32 PM
Post
#5
|
|
![]() Squeeze Machine ![]() Posts: 766 Joined: 13-February 08 From: Catching the squeezed drips downunder. |
Hmm.. I went to the reply page and viwed source but couldn't see it anywhere or in any of the files with other jQuery stuff.
It could be that jQuery is in noConflict mode as well? -------------------- |
|
|
Sep 3 2008, 10:10 PM
Post
#6
|
|
![]() Co-Founder ![]() Posts: 2,664 Joined: 13-February 08 From: On the forum! |
It's in there...
CODE <script type="text/javascript" src="jscripts/ips_editor_confirm.js"></script>
-------------------- Thanks,
Jacob |
|
|
Sep 3 2008, 11:04 PM
Post
#7
|
|
![]() Squeeze Machine ![]() Posts: 766 Joined: 13-February 08 From: Catching the squeezed drips downunder. |
Could we have a JavaScript confirm when a new topic page is closed and something is entered into the content box. It is a rare occurrence but twice now I have accidentally closed down a thread I have been working on. Ah! You only need to use one half of that script -- the top half if jQuery is on the forum and the bottomw half if not -- jQuery is there so you would use... CODE $(document).ready(function() {
$('textarea, input').change(function() { $(window).unload(function (e) { if (confirm('Are you sure you would like to move away from this page? You changes will be lost')) return true else e.preventDefault(); }); }); }); -------------------- |
|
|
Sep 3 2008, 11:35 PM
Post
#8
|
|
![]() Co-Founder ![]() Posts: 2,664 Joined: 13-February 08 From: On the forum! |
Okay, well now it works. However, if you click okay it still moves pages, as well as cancel. Weird.
-------------------- Thanks,
Jacob |
|
|
Sep 3 2008, 11:53 PM
Post
#9
|
|
![]() Squeeze Machine ![]() Posts: 766 Joined: 13-February 08 From: Catching the squeezed drips downunder. |
CODE $(document).ready(function() { $('textarea, input').change(function() { $(window).bind('unload,close', function (e) { if (confirm('Are you sure you would like to move away from this page? You changes will be lost')) return true else { e.preventDefault(); return false; } }); }); }); Maybe that will help? -------------------- |
|
|
Sep 4 2008, 12:16 AM
Post
#10
|
|
![]() Squeeze Machine ![]() ![]() ![]() ![]() ![]() Posts: 733 Joined: 13-February 08 From: Borneo |
Where is this for me to test?
-------------------- |
|
|
Sep 4 2008, 12:33 AM
Post
#11
|
|
|
Rapid Squeezer ![]() Posts: 308 Joined: 15-February 08 From: Finland |
Click "Add Reply" and then click a link to away from that page. I guess Jacob hasn't made the latest change yet. Is it possible to extend this to browser's back button as well?
-------------------- |
|
|
Sep 4 2008, 04:47 AM
Post
#12
|
|
|
Master of the Universe ![]() Posts: 1,298 Joined: 15-February 08 From: London, England |
This is firing when the form is submitted, this is obviously incorrect as submitting the form is the goal of posting.
-------------------- |
|
|
Sep 4 2008, 05:23 AM
Post
#13
|
|
![]() Squeeze Machine ![]() Posts: 766 Joined: 13-February 08 From: Catching the squeezed drips downunder. |
This is firing when the form is submitted, this is obviously incorrect as submitting the form is the goal of posting. CODE $(document).ready(function() {
$('textarea, input').change(function() { $(window).bind('unload,close', function (e) { if (confirm('Are you sure you would like to move away from this page? You changes will be lost')) return true else { e.preventDefault(); return false; } }); }); $('form").submit( function () { $(window).unbind('unload,close'); }); $('input[type="submit"]').click( function () { $(window).unbind('unload,close'); }); }); -------------------- |
|
|
Sep 4 2008, 08:12 AM
Post
#14
|
|
|
Master of the Universe ![]() Posts: 1,298 Joined: 15-February 08 From: London, England |
The preview button needs to be removed from this as well
Also there is something weird happening in FF3. It asks if I want to navigate away from the page. I then click OK x amount of times. Nothing happens, it just keeps asking. Then I have to press cancel for the amount of times I clicked ok + 1 to move away from the page. Is anyone else having this? -------------------- |
|
|
Sep 4 2008, 08:27 AM
Post
#15
|
|
![]() Squeeze Machine ![]() Posts: 766 Joined: 13-February 08 From: Catching the squeezed drips downunder. |
The code hasn't changed since Jacob's last reply so everything is as it was.
-------------------- |
|
|
Sep 4 2008, 02:58 PM
Post
#16
|
|
![]() Co-Founder ![]() Posts: 2,664 Joined: 13-February 08 From: On the forum! |
I've changed it, but it appears not to be working at all now.
-------------------- Thanks,
Jacob |
|
|
Sep 4 2008, 05:50 PM
Post
#17
|
|
![]() Squeeze Machine ![]() Posts: 766 Joined: 13-February 08 From: Catching the squeezed drips downunder. |
I've changed it, but it appears not to be working at all now. I'm confused... I changed the script and uploaded it and it appears to work but there is another confirm element coming from somewehere with the text "Are you sure you would like to navigate away from this page. Press OK to confirm" Anyone know where that is? -------------------- |
|
|
Sep 4 2008, 08:15 PM
Post
#18
|
|
![]() Squeeze Machine ![]() Posts: 766 Joined: 13-February 08 From: Catching the squeezed drips downunder. |
I turned the code off for you -- by commenting code out, there will be no messages at this stage until I can figure out where the second confirm message is coming from (that now no longer appears that I have commented out by code) -- odd
-------------------- |
|
|
If you found The Web Squeeze to be helpful, please donate so we can keep this site FREE, FRESH, and fortified with Web Design & Development info!
![]() ![]() |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
Similar Topics
| Topic Title | Replies | Topic Starter | Views | Last Action | ||
|---|---|---|---|---|---|---|
![]() |
8 | Mark | 592 | 10th March 2008 - 04:33 PM Last post by: Jacob |
||







Sep 3 2008, 05:09 PM












