Replace Selected Content

Replace Selected Content


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.


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.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several