Modify the DOM?

This is a discussion on "Modify the DOM?" within the JavaScript Forum section. This forum, and the thread "Modify the DOM? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 19th, 2007, 20:48
New Member
Join Date: Sep 2007
Location: Berlin
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Modify the DOM?

Hi
I want to send a selected text to the google translator (http://www.google.com/translate_t) and insert the translated text on the fly into the DOM of the page, so that it replaces the old text.
Now the problem: I only send the text to google translate and get a text back (without the tags) - but how do I keep the html-tags, so that when I insert the translated text into the DOM, it displays correctly?

For example you have "<div>Some text and <b>some bold</b> words.</div>". The user selects "Some text and some bold words.", it gets translated, and inserted back in as "Etwas Text und einige fette Wörter." But the tags are missing and it doesn't display correctly.

I do it this way:

HTML: Select all
var range = text.getRangeAt(0);
range.deleteContents();
newnode = document.createElement("a");
newnode.appendChild(document.createTextNode(translated_text));
range.insertNode(newnode);
How can I overcome this and re-insert the tags in the right place?

Any help would be appreciated.
Reply With Quote

  #2 (permalink)  
Old Sep 19th, 2007, 23:01
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Modify the DOM?

That would be very confusing
you'd have to send everything in sections and piece it back together i think
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to modify a website creomte Starting Out 3 Feb 19th, 2008 11:33
[SOLVED] How to modify lists thewebkid Web Page Design 3 Nov 26th, 2007 12:10
How to Modify Existing SWF file khwo Flash & Multimedia Forum 21 Oct 28th, 2006 19:26
Can Anyone Modify This Script? gajlehab JavaScript Forum 0 Jan 20th, 2006 14:27
Cannot modify header information - headers already sent Tim356 PHP Forum 2 Aug 7th, 2005 22:58


All times are GMT. The time now is 00:09.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43