WordPress.org

Make WordPress Core

Opened 10 years ago

Closed 7 years ago

Last modified 7 years ago

#4196 closed enhancement (fixed)

"Are you sure you want to navigate away from this page?" prompt when not using the RTE

Reported by: johnbillion Owned by: westi
Milestone: 2.9 Priority: normal
Severity: normal Version: 2.1.3
Component: Autosave Keywords: quicktags onbeforeunload reporter-feedback
Focuses: Cc:

Description

When using the RTE, if you make changes to your post and then attempt to navigate away from the page without saving the changes, a nice prompt appears asking for confirmation that you want to navigate away.

The attached patch applies this same confirmation system to the non-RTE editor.

I've added it to wp-includes/js/quicktags.js as I though that was the most logical file to put it in, seeing as it's only for non-RTE editing. If anyone can think of a better place then please holla.

Tested in Fx2 and IE7.

Attachments (5)

4196.diff (1.2 KB) - added by johnbillion 10 years ago.
confirm.png (6.8 KB) - added by johnbillion 10 years ago.
Screenie
4196.my.diff (1.6 KB) - added by rob1n 10 years ago.
4196.2.diff (1.7 KB) - added by johnbillion 10 years ago.
4196.3.diff (1.6 KB) - added by johnbillion 9 years ago.
Patch refreshed, and prompt no longer displayed if content field is empty

Download all attachments as: .zip

Change History (26)

@johnbillion
10 years ago

#1 @johnbillion
10 years ago

  • Keywords has-patch added

Patchy patchy.

@johnbillion
10 years ago

Screenie

#2 @foolswisdom
10 years ago

  • Milestone set to 2.3

#3 @rob1n
10 years ago

  • Owner changed from anonymous to rob1n

#4 @andy
10 years ago

What about FF1.5 and IE6?

#5 @johnbillion
10 years ago

Just tested in IE6 on XP and Firefox 1.5 on Vista, both work no problem.

#6 @rob1n
10 years ago

Verified works on Safari 2.0.4, 419.3. I'm downloading the latest nightly of WebKit to test that, too.

#7 @rob1n
10 years ago

Works in WebKit r21081.

#8 @johnbillion
10 years ago

Fails with Opera, but the RTE version of this doesn't work in Opera either as the onbeforeunload event isn't supported in Opera.

#9 @andy
10 years ago

Thanks for testing.

#10 @rob1n
10 years ago

  • Status changed from new to assigned

@rob1n
10 years ago

@johnbillion
10 years ago

#11 @johnbillion
10 years ago

rob1n, your new patch doesn't seem to work. On line 402 of wp-includes/js/quicktags.js there is no need for to call confirm as this is handled automatically by the browser.

The onbeforeunload event is a strange one indeed. All you need to pass to it is a string which then gets displayed in a prompt (screenshot). The string is prepended with "Are you sure you want to navigate away from this page?" and appended with "Press OK to continue or Cancel to stay on the current page." This is cross-browser (IE and Fx at least) functionality.

Also, the check for emptiness in the content area needs to use innerText and not innerHTML.

HOWEVER. All that said, I've just noticed a bug in that (with my first patch applied) the prompt appears when you hit one of the submit (Save/Publish, etc) buttons and it shouldn't.

New patch attached.

#12 @andy
10 years ago

Thanks for the good info johnbillion!

#13 @rob1n
10 years ago

  • Status changed from assigned to new

#14 @Speedboxer
9 years ago

The latest patch works in IE7 (up-to-date) and FF 2.0.0.6 (latest) on Windows Vista (Home Premium).

Doesn't work in Opera 9.23 (latest) and Safari 3.0.3 BETA (latest, for Windows).

One thing I noticed is that if you type something in the entry box, and then clear it, you still get the confirm message.

You get no message if the entry box is empty but either (or both) the title and tags boxes are filed. Is this intended/what we want?

@johnbillion
9 years ago

Patch refreshed, and prompt no longer displayed if content field is empty

#15 @johnbillion
9 years ago

Patch refreshed. Candidate for 2.3?

#16 @ryan
9 years ago

  • Milestone changed from 2.3 to 2.4

#17 @westi
9 years ago

  • Owner changed from rob1n to westi
  • Status changed from new to assigned

#18 @darkdragon
9 years ago

  • Milestone changed from 2.5 to 2.6

No Traction, moving to 2.6, pending testing of the patch with TinyMCE 3.0.x

#19 @Denis-de-Bernardy
7 years ago

  • Component changed from Administration to Autosave
  • Keywords reporter-feedback added; has-patch removed
  • Milestone changed from 2.9 to Future Release

isn't this fixed?

#20 @azaozz
7 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

Yes, fixed.

#21 @westi
7 years ago

  • Milestone changed from Future Release to 2.9
Note: See TracTickets for help on using tickets.