dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: DHTML
Expertise: Beginner
Nov 3, 1999

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Replace Selected Content

Question:

How do I replicate the pasteHTML function supported by Internet Explorer in Netscape? Rewriting the layer isn't the problem. The problem is determining the position of the text returned by the getSelection(). For example, how would I allow a user to select a piece of text on the screen and modify it (i.e. make it bold)? If the selected word appears more than once in the text, I can't just find() it.

Answer:

You will not be able to do what you want with Navigator. IE supports replacement of the selected content. Navigator 4.x does not. All you can do to replace the contents with Navigator (at least with Navigator 4.x at this time) is to use document.write to a positioned DIV or SPAN block, or to a layer. You won't be able to replace content based on a person selecting text from the page.

The best you can hope for is layer your entire Web page, capture the mouse click events for each layer, and when the person "applies" something to the selection, recreate the entire block, but this time add the strong tags ("") to the "selected" content. This means you would need to be able to recreate each layer, so you're probably looking at putting page content into an array for just this purpose. This could be messy, but it is a place for you to start if you absolutely have to have this type of functionality.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date