A
Andrew Crowe
Hi,
I've been trying to edit an inbrowser WYSIWYG editor that relies on
execCommand for most of its operations.
I would like a dropdown of styles that a user can choose and are applied
to the outer tag of their current selection.
I've created the following by editing an example I found online but it
only works in IE:
function SelectClass(selectname) {
if (selectname.selectedIndex != 0) {
option=selectname.options[selectname.selectedIndex].value;
selectname.selectedIndex = 0;
if (browser.isIE5up) {
sel = EpozElement.contentWindow.document.selection;
range = sel.createRange();
el = range.parentElement();
}else{
sel = EpozElement.contentWindow.window.getSelection();
range = sel.getRangeAt(0);
el = range.parentNode;
}
if (option != 'none') {
el.className = option;
}
if (option == 'none') {
el.removeAttribute('className');
}
EpozElement.contentWindow.focus();
}
}
I've tried a few things but I can't work out what the Mozilla equivalent
to range.parentElement() is.
If anyone can see how I can get that to work in Mozilla, or knows of a
way to do this using execCommand then that'd be much appriciated
Thanks
Andrew
I've been trying to edit an inbrowser WYSIWYG editor that relies on
execCommand for most of its operations.
I would like a dropdown of styles that a user can choose and are applied
to the outer tag of their current selection.
I've created the following by editing an example I found online but it
only works in IE:
function SelectClass(selectname) {
if (selectname.selectedIndex != 0) {
option=selectname.options[selectname.selectedIndex].value;
selectname.selectedIndex = 0;
if (browser.isIE5up) {
sel = EpozElement.contentWindow.document.selection;
range = sel.createRange();
el = range.parentElement();
}else{
sel = EpozElement.contentWindow.window.getSelection();
range = sel.getRangeAt(0);
el = range.parentNode;
}
if (option != 'none') {
el.className = option;
}
if (option == 'none') {
el.removeAttribute('className');
}
EpozElement.contentWindow.focus();
}
}
I've tried a few things but I can't work out what the Mozilla equivalent
to range.parentElement() is.
If anyone can see how I can get that to work in Mozilla, or knows of a
way to do this using execCommand then that'd be much appriciated
Thanks
Andrew