A
Andrew Crowe
Hi,
I've got a function to get data from a text selection in a users browser:
function class_getSelection(){
if (browser.isIE5up) {
return EpozElement.contentWindow.document.selection;
} else {
return EpozElement.contentWindow.window.getSelection();
};
}
I've then got functions that get the parent tag from the selection:
function class_getSelectionRange(){
sel = class_getSelection();
if (browser.isIE5up) {
return sel.createRange();
} else {
return sel.anchorNode;
};
}
function class_getSelectionParent(){
range = class_getSelectionRange();
if (browser.isIE5up) {
return range.parentElement();
} else {
return range.parentNode;
};
}
From this I'd like to find out if the user's selection covers the
entire tag (eg. they've highlited an entire paragraph) or just a
sentence in the paragraph). I've tried
selection=class_getSelection();
object=class_getSelectionParent();
if(selection==object.innerHTML)
but unfortunately selection is just the text and innerHTML includes html
tags / special breaks etc. Is there any way to compare selection and
innerHTML to work out whether they point to the same thing (eg. the user
has highlited the entire block).
Thanks
Andrew
I've got a function to get data from a text selection in a users browser:
function class_getSelection(){
if (browser.isIE5up) {
return EpozElement.contentWindow.document.selection;
} else {
return EpozElement.contentWindow.window.getSelection();
};
}
I've then got functions that get the parent tag from the selection:
function class_getSelectionRange(){
sel = class_getSelection();
if (browser.isIE5up) {
return sel.createRange();
} else {
return sel.anchorNode;
};
}
function class_getSelectionParent(){
range = class_getSelectionRange();
if (browser.isIE5up) {
return range.parentElement();
} else {
return range.parentNode;
};
}
From this I'd like to find out if the user's selection covers the
entire tag (eg. they've highlited an entire paragraph) or just a
sentence in the paragraph). I've tried
selection=class_getSelection();
object=class_getSelectionParent();
if(selection==object.innerHTML)
but unfortunately selection is just the text and innerHTML includes html
tags / special breaks etc. Is there any way to compare selection and
innerHTML to work out whether they point to the same thing (eg. the user
has highlited the entire block).
Thanks
Andrew