Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-27-2007, 07:54 PM
Aytrydez Aytrydez is offline
 
Join Date: Jul 2007
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Appending Text to vb Editor Textarea

I need a way to have a Javascript function append text to the vbulletin editors textarea when posting a new thread/post. I have written a custom image upload script for my forum that is used during new posts, it allows a member to select an image, upload it to the server and then provides a reference to the image in the form of a link, what I have tried to do is write a javascript function that will take the link and format a string with bb IMG tags, and then append the string to the VB Editor textarea, however when i reference the textarea by id in javascript, using getElementsById('VB_Editor_001_textarea') and subsequently try to append a string to the value property of the element, i receive this error in firefox:
Code:
Error: [Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMNSHTMLDocument.queryCommandState]"  nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)"  location: "JS frame :: http://orlounge.com/forum/clientscript/vbulletin_textedit.js?v=364 :: anonymous :: line 1415"  data: no]
Source File: http://orlounge.com/forum/clientscript/vbulletin_textedit.js?v=364
Line: 1415
any help would be appreciated.
Reply With Quote
  #2  
Old 07-28-2007, 08:38 AM
testebr testebr is offline
 
Join Date: Jan 2004
Posts: 353
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try it:

window.frames['vB_Editor_001_iframe'].document.body.innerHTML

Work only with Internet Explorer. If you know how to do to work in other browser please share info here.
Reply With Quote
  #3  
Old 08-07-2007, 04:43 AM
testebr testebr is offline
 
Join Date: Jan 2004
Posts: 353
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ohhhh I found the solution:

Code:
document.getElementById('vB_Editor_001_iframe').contentWindow.document.body.innerHTML
Reply With Quote
  #4  
Old 08-07-2007, 05:29 AM
Darkwaltz4's Avatar
Darkwaltz4 Darkwaltz4 is offline
 
Join Date: Oct 2002
Location: Chicago
Posts: 1,538
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

use the vb javascript function

fetch_object('vB_Editor_001_iframe').innerHTML = 'whatever';

it takes care of browser compatibility for you
Reply With Quote
  #5  
Old 08-07-2007, 06:59 PM
testebr testebr is offline
 
Join Date: Jan 2004
Posts: 353
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Your solution doesn't work. Try it:

<input type="button" name="test" value="test" onClick="fetch_object('vB_Editor_001_iframe').inne rHTML = 'whatever';">
Reply With Quote
  #6  
Old 08-07-2007, 07:05 PM
Aytrydez Aytrydez is offline
 
Join Date: Jul 2007
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i actually found a different way, using one of the functions from the text editor itself, the function:

Code:
vB_Editor['vB_Editor_001'].insert_text(text)
seems to work well for what i needed, though there does seem to be an error from the text editor whenever anything is inserted in firefox at least, either using the function or referencing the textarea through javascript dom, though the error doesn't affect anything in the editor or posting, that i have seen.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:38 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03438 seconds
  • Memory Usage 2,206KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete