The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Insert text into WYSIWYG Editor via link
I have seen a few requests for this in the past, however I cannot seem to understand how to achieve the same effect for the WYSIWYG editor as I have for the standard text editor.
All I am trying to do is have text appear in the textarea when creating a new post based on clicking a link, similar to how you click on a smilie and it appears inside the editor. Here is my code: Code:
<script type="text/javascript"> function insert(el,ins) { if (el.setSelectionRange){ el.value = el.value.substring(0,el.selectionStart) + ins + el.value.substring(el.selectionStart,el.selectionEnd) + el.value.substring(el.selectionEnd,el.value.length); } else if (document.selection && document.selection.createRange) { el.focus(); var range = document.selection.createRange(); range.text = ins + range.text; } } </script> Code:
<input type="button" value="hello" onclick="insert(this.form.{$editorid}_textarea,'hello')"> --------------- Added [DATE]1209215442[/DATE] at [TIME]1209215442[/TIME] --------------- === UPDATE === ????????????????? Alright, I have made some progress and have found a partial solution but require someones helpful guidance with javascript in order to make it fully functional. Here is my dilemma. I have 2 javascripts which I need to merge. Here is the first: Code:
<script type="text/javascript"> function insert(el,ins) { if (el.setSelectionRange){ el.value = el.value.substring(0,el.selectionStart) + ins + el.value.substring(el.selectionStart,el.selectionEnd) + el.value.substring(el.selectionEnd,el.value.length); } else if (document.selection && document.selection.createRange) { el.focus(); var range = document.selection.createRange(); range.text = ins + range.text; } } </script> Code:
<input type="button" value="test" onclick="insert(this.form.{$editorid}_textarea,'test123')"> Code:
<script> function insertText() { var textstring = "Insert me into the Iframe please"; document.getElementById ("{$editorid}_iframe").contentWindow.document.body.innerHTML = textstring; } </script> Code:
<a href="javascript:;" onClick="insertText()">test</a> --- Bottom line, I'd like to have a dual action javascript which allows for the detection of {$editorid}_textarea being the textarea (standard editor) and {$editorid}_iframe being an iframe (wysiwyg editor)and allows for specific content to be placed within both via an OnClick event from a link. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|