Hi!
Sorry for may bad english!
How to add a function that will add some text in textarea, when someone clicks on button, where the cursor is?
(Like here, on daniweb textareas!)
eg. There is bold button! The user clicks on it, and the text "[BOLD][/BOLD]" writes where curser/caret is. Cursor/caret (|) is focused between these two elements "[BOLD]cursor/caret (|)[/BOLD]"
Thanks!

Recommended Answers

All 8 Replies

You are looking for is a functionality in WYSIWYG editor. You may search for window.getSelection() for FF or others, and document.selection.createRange() for IE.

Ok. Thanks!
Another thing:
If browser doesn't support this, then will be redirect to some other page. How to do that?
If browser doesn't support this because his version (too old), the will be redirect to some other page. How to that.
(with javascript)
Thanks!

Can you write some example with option 'bold'?
(I don't understand English well)
Thanks!
PS. What is the name of this editor (on daniweb); editor without formating text (eg [bold][/bold] and not bold!)

I found this: Click
Problem:
Can anybody write in javascript script that will set the cursor/caret between tags (eg. function writes '<strong></strong>', and between these two tags must be cursor/caret (also: <strong>Here's cursor</strong>))
Thanks!

If browser doesn't support this, then will be redirect to some other page. How to do that?
If browser doesn't support this because his version (too old), the will be redirect to some other page. How to that.
(with javascript)

If a browser does not support JavaScript, you can't redirect the page to anything! What you can do is to add <noscript> tag inside the area you are trying to display with a link. If a browser does not support JavaScript (disable), the content inside <noscript></noscript> will be displayed instead.

editor without formating text (eg [bold][/bold] and not bold!)

I think it is call bbcode.

between these two tags must be cursor/caret (also: <strong>Here's cursor</strong>))

I'm sorry, I don't understand this... :(

There is a button (eg. B - bold; the same as in editor on this site). When I click on "B" in this editor on this site, in "<textarea>" write , and the cursor position (see the picture) is set between these two functions. How is that made?

Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.