0

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!

Edited by ivan3510: n/a

2
Contributors
8
Replies
9
Views
7 Years
Discussion Span
Last Post by ivan3510
0

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.

0

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!

0

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!)

Edited by ivan3510: n/a

0

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!

0

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... :(

0

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?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.