944,045 Members | Top Members by Rank

Ad:
Dec 8th, 2006
0

change the font/color of the selected text on a web page through javascript

Expand Post »
Hi
I want to write a javascript program which will change the font/color of the user selcted text on a web page.
Is it possible to know the exact location of the selected text from the web page.
I want a user to select a text on a web page and then my javascrip code should locate this text in the web page's source file.
I dont want to search for this text in the source file of the web page.
please help!!!!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kamleshpdude is offline Offline
4 posts
since Nov 2006
Dec 8th, 2006
0

Re: change the font/color of the selected text on a web page through javascript

Hi
I am working on javascript wherein i am trying to highlight the
selected text by changing its background color.

What I want exactly is:
1) When a page is loaded, the user will select some text on the page by
clicking and draggin the mouse
2) I am able to extract the selected text as a string
3) I want to access the exact position of the selected text in the
document object I am using in javascript

Can you please tell me how to access the exact position of text at some
position in the HTML page using the document object, since the same
text string can appear multiple times in the HTML page.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kamleshpdude is offline Offline
4 posts
since Nov 2006
Dec 10th, 2006
0

Re: change the font/color of the selected text on a web page through javascript

Here is a script that captures any text that has been highlighted with the cursor. In Internet Explorer, it even grabs text highlighted within a text box or textarea.

http://javascript.internet.com/page-...hted-text.html

It shouldn't be to much of a stretch to modify the code to change font size and color instead of copying it to a textbox.
Team Colleague
Reputation Points: 92
Solved Threads: 21
Posting Pro in Training
FC Jamison is offline Offline
436 posts
since Jun 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Interpret HTTP (Content-Disposition) headers from an XMLHTTP object?
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Re: Cancelling a Search





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC