htmlArea

A directory of browser-based WYSIWYG editors

  MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN

Home: htmlArea 3 (beta): htmlArea 2 & 3 archive (read only): htmlArea v3.0 - Discussion:
[BUG] in function ie_checkBackspace


The htmlArea 2 & 3 editors have been discontinued.

We've made these forums available as a read-only reference and knowledge-base for people using or developing editors based on htmlArea 2 or 3.

Anyone who is interested in taking over version 2 or 3 is free to do so. All we ask is that you choose a new name that doesn't have "htmlarea" in it to avoid confusion with this site. We'll even give you a link in the directory to make it easier for people to find you. If you are developing or hosting an htmlArea based-editor under a new name, please submit it to our directory.

 


t0mmy
Novice

Sep 28, 2004, 4:37 AM

Post #1 of 4 (4726 views)
Shortcut
[BUG] in function ie_checkBackspace Can't Post

Hello!

Here's my bug report: http://sourceforge.net/tracker/index.php?func=detail&atid=525656&aid=1036042&group_id=69750

Anyone get this error too? Are there any solutions for this problem?

t0mmy

edit:

I've surrounded the statements of this function with a try...catch statement. Hope this helps!



Code
HTMLArea.prototype.ie_checkBackspace = function() { 
var sel = this._getSelection();
var range = this._createRange(sel);
// the following throws an error in M$IE, if a table is selected
try {
var r2 = range.duplicate();
r2.moveStart("character", -1);
var a = r2.parentElement();
if (a != range.parentElement() &&
/^a$/i.test(a.tagName)) {
r2.collapse(true);
r2.moveEnd("character", 1);
r2.pasteHTML('');
r2.select();
return true;
}
} catch (e) {
// do nothing
}
};


_____________


"Grass is for the ass, 'erb is for mankind." - Bob Marley



(This post was edited by t0mmy on Sep 28, 2004, 4:54 AM)


alley
New User

Jan 6, 2005, 4:52 AM

Post #2 of 4 (4630 views)
Shortcut
Re: [t0mmy] [BUG] in function ie_checkBackspace [In reply to] Can't Post

I don't understand exactly when this function will return true... when do you NOT want to delete something when pressing del...

anyway, here's a fix for the bug. If a control's selected, return and don't check any longer:


Code
HTMLArea.prototype.ie_checkBackspace = function() { 
var sel = this._getSelection();
if (sel.type == "Control") //ie an image is selected
return;
var range = this._createRange(sel);
var r2 = range.duplicate();
r2.moveStart("character", -1);
var a = r2.parentElement();
if (a != range.parentElement() &&
/^a$/i.test(a.tagName)) {
r2.collapse(true);
r2.moveEnd("character", 1);
r2.pasteHTML('');
r2.select();
return true;
}
};



tadaske
New User

Jan 6, 2005, 8:18 PM

Post #3 of 4 (4600 views)
Shortcut
Re: [alley] [BUG] in function ie_checkBackspace [In reply to] Can't Post

Hi.
I applied your code.
With this, image had disappeared when Delete Key was pushed.
it is good.
but, With this, all html code had disappeared when BackSpace Key was pushed.
I added change to your code.
How about such a change?


Code
HTMLArea.prototype.ie_checkBackspace = function() { 
var sel = this._getSelection();
if (sel.type == "Control"){
var el = this.getParentElement();
var p = el.parentNode;
p.removeChild(el);
return true;
} else {
var range = this._createRange(sel);
var r2 = range.duplicate();
r2.moveStart("character", -1);
var a = r2.parentElement();
if (a != range.parentElement() && /^a$/i.test(a.tagName)) {
r2.collapse(true);
r2.moveEnd("character", 1);
r2.pasteHTML('');
r2.select();
return true;
}
}
};



alley
New User

Jan 7, 2005, 2:09 AM

Post #4 of 4 (4591 views)
Shortcut
Re: [tadaske] [BUG] in function ie_checkBackspace [In reply to] Can't Post

You're right...thank you


In Reply To
Hi.
I applied your code.
With this, image had disappeared when Delete Key was pushed.
it is good.
but, With this, all html code had disappeared when BackSpace Key was pushed.
I added change to your code.
How about such a change?


Code
HTMLArea.prototype.ie_checkBackspace = function() { 
var sel = this._getSelection();
if (sel.type == "Control"){
var el = this.getParentElement();
var p = el.parentNode;
p.removeChild(el);
return true;
} else {
var range = this._createRange(sel);
var r2 = range.duplicate();
r2.moveStart("character", -1);
var a = r2.parentElement();
if (a != range.parentElement() && /^a$/i.test(a.tagName)) {
r2.collapse(true);
r2.moveEnd("character", 1);
r2.pasteHTML('');
r2.select();
return true;
}
}
};



 
 
 


Search for (options)