User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,912 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,643 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 5647 | Replies: 2
Reply
Join Date: Nov 2006
Posts: 4
Reputation: kamleshpdude is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kamleshpdude kamleshpdude is offline Offline
Newbie Poster

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

  #1  
Dec 8th, 2006
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!!!!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2006
Posts: 4
Reputation: kamleshpdude is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kamleshpdude kamleshpdude is offline Offline
Newbie Poster

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

  #2  
Dec 8th, 2006
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.
Reply With Quote  
Join Date: Jun 2004
Location: Hemet, CA
Posts: 427
Reputation: FC Jamison is on a distinguished road 
Rep Power: 5
Solved Threads: 17
Colleague
FC Jamison's Avatar
FC Jamison FC Jamison is offline Offline
Posting Pro in Training

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

  #3  
Dec 10th, 2006
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 7:49 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC