/    Sign up×
Community /Pin to ProfileBookmark

Selection and TextRange object in IE

Hi experts!
I just want to know if there is a way through which i can check that a particular DOM element exists in a user selection (selection object) in Internet Explorer.
In Firefox, i am able to use the method containsNode(node, flag) defined in Selection Object which returns true/false based on whether the passed node is contained in the user selection.
But in IE, i could not find a way to do the same. containsNode seems to have not been implemented in IE
Pls, can anyone help me out to do the same.
I have been digging on this for so long thats frustrating me ?
Expecting a reply soon!
thanks
Sangeetha

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@MrNobodyJan 01.2009 — If the selection object is for a control range, then you can loop through the controlRange collection to see if the node in question is present. I copied the following, with one correction, from the MSDN website:
[CODE] if (document.selection.type == "control"){
var oControlRange = document.selection.createRange();
for (i = 0; i < oControlRange.length; i++)
if (oControlRange(i).tagName != "IMG")
oControlRange(i).style.fontFamily=event.srcElement.style.fontFamily;
}[/CODE]
Copy linkTweet thisAlerts:
@SangeeKarthikauthorJan 02.2009 — Hey MrNobody!

Thanks for ur reply. But my selection is not a control selection. Its a text selection. So your code wont suit me.

Please help me with my problem on text selection.

Expecting ur reply soon

Thanks

Sangeetha
Copy linkTweet thisAlerts:
@MrNobodyJan 02.2009 — A text selection contains no nodes.
×

Success!

Help @SangeeKarthik spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...