Ismet posted on January 31, 2010 05:01

I write a lot of content using
DotNetNuke and sometimes i accidentaly press on Backspace button on my keyboard while cursor focused at outside of
HTML area. This causes losing content and it is a very bad moment when you have a lot of text inside this HTML area.
I had to apply a workaround to
prevent content loss when i press on Backspace button. First of all create a
javascript file (e.g PreventReturn) under JS directory of your
DotNetNuke installation.
Paste following text inside
PreventReturn.js:
window.onbeforeunload = function() {
if(!confirm("Are you sure you want to leave the page?")) return false;
}
Save the javascript file under js directory of your website root directory. After that you will need to call this file from
controls\texteditor.ascx file.
Browse
Controls directory and open the
texteditor.ascx file with a text editor.
Insert:
<script language="javascript" src="/js/PreventReturn.js"></script>
After following:
<%@ Control language="vb" AutoEventWireup="false" Explicit="True" Inherits="DotNetNuke.UI.UserControls.TextEditor" %>
<%@ Register TagPrefix="dnn" TagName="label" Src="~/controls/labelControl.ascx" %>
Save and close the texteditor.ascx file.
This will help you to prevent returning to previous page while creating and editing content on your
DotNetNuke portal. However, you will need to repeat the process everytime a new
DotNetNuke release comes up and upgrades applied to your portal.