...

View Full Version : JavaScript: WYSIWYG Editor... Object selection, Mozilla



goldrake73
10-22-2004, 03:20 PM
Hello, I'am building a wysiwyg editor and I have trouble to detect an object like a TABLE, an IMAGE etc...
I found this method but it only works with MSIE...
Is there a way to do the same thing in MOZILLA ???

Here is my code...


if (this.myEditor.document.selection.type == 'Control')
{
var range = this.myEditor.document.selection.createRange();
// Check if one object is selected
if (range.length == 1 && (range(0).tagName == 'TABLE' || range(0).tagName == 'table'))
{
current_width=range(0).width;
current_height=range(0).height;
current_border=range(0).border;
current_bordercolor=range(0).borderColor;
current_cellspacing=range(0).cellSpacing;
current_cellpadding=range(0).cellPadding;
current_align=range(0).align;
current_bgcolor=range(0).bgColor;
alert (current_width);
// alert other variables to view...
return true;
}
}

Kor
11-08-2004, 10:24 AM
there might be getSelection() method... I read about it but never used or tested it...

liorean
11-08-2004, 01:52 PM
Microsoft made their own text ranges and selection mechanism. Mozilla uses the standard one. See <http://www.mozilla.org/docs/dom/domref/dom_range_ref.html> for ranges, <http://www.mozilla.org/docs/dom/domref/dom_window_ref24.html#1000044> for the window.getSelection method, and <http://unstable.elemental.com/mozilla/build/latest/mozilla/content/dox/interfacensISelection-members.html> for the Selection object.

The best resource explaining these concepts is sadly no longer online, but I've found a cached version of it in the wayback machine <http://web.archive.org/web/20030724060903/pbwizard.com/Articles/Moz_Range_Object_Article.htm>. Beware that this page might disappear at any time, though.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum