Advanced HTML Editor 2 Support Product Page
This topic was archived
API to Interact with Editor?
Asked 02 Nov 2004 15:59:11
1
has this question
02 Nov 2004 15:59:11 David Aguilera posted:
I have merge codes that users can insert into the content they write. Is there a way that I can interact with the HTML Editor to load these codes into the edit box when selected by a user? Replies
Replied 02 Nov 2004 16:17:03
02 Nov 2004 16:17:03 Camillah Ringes replied:
Hi David,
I did post something about this issue also in the HTML editor 1 forum:
www.dmxzone.com/forum/topic.asp?TOPIC_ID=29839
I just copy the text over here and adjust it a bit(see for the context the post above):
It's quite important to know if you want to
change the whole content, or add something to it. Just changing everything in the
content window is quite simple and goes like this (it's a long line):
<pre id=code><font face=courier size=2 id=code>var objname ="theTextareaId";
document.getElementById('_' + objname + '_editor').contentWindow.document.body.innerHTML = "newvalue"; </font id=code></pre id=code>
When wanting to add something to the content it is getting a bit more complicated.
You have to get the range and insert a new node into the document. IE and mozilla
handle these kind of functions differently.
If you want to use the above code with the version 1 editor you have to put an
extra attribute in the textarea tag defining the id. Be sure you name the id yhe same
way as the name attribute wich is already there. In version 2 the id gets inserted
automaticly. The above 'var objname' has to get the value of the id attribute.
The ' newvalue' above is the text or HTML that get's inserted to the editor.
Are you already a bit familiar with DHTML? For IE you can get good info at this site:
msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/dhtml_reference_entry.asp
This site also contains a library where you can look up all functions and methods.
For gecko based browsers this site is recommendable:
www.mozilla.org/docs/dom/domref/dom_shortTOC.html
It's not as detailed as the microsoftsite but it has a nice overview of all the things
and functions needed for coding for gecko (mozilla)
--------------------------------------------------
Camillah Ringes
Web Developer at Dynamic Zones
Manager at DMXzone.com
--------------------------------------------------
I did post something about this issue also in the HTML editor 1 forum:
www.dmxzone.com/forum/topic.asp?TOPIC_ID=29839
I just copy the text over here and adjust it a bit(see for the context the post above):
It's quite important to know if you want to
change the whole content, or add something to it. Just changing everything in the
content window is quite simple and goes like this (it's a long line):
<pre id=code><font face=courier size=2 id=code>var objname ="theTextareaId";
document.getElementById('_' + objname + '_editor').contentWindow.document.body.innerHTML = "newvalue"; </font id=code></pre id=code>
When wanting to add something to the content it is getting a bit more complicated.
You have to get the range and insert a new node into the document. IE and mozilla
handle these kind of functions differently.
If you want to use the above code with the version 1 editor you have to put an
extra attribute in the textarea tag defining the id. Be sure you name the id yhe same
way as the name attribute wich is already there. In version 2 the id gets inserted
automaticly. The above 'var objname' has to get the value of the id attribute.
The ' newvalue' above is the text or HTML that get's inserted to the editor.
Are you already a bit familiar with DHTML? For IE you can get good info at this site:
msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/dhtml_reference_entry.asp
This site also contains a library where you can look up all functions and methods.
For gecko based browsers this site is recommendable:
www.mozilla.org/docs/dom/domref/dom_shortTOC.html
It's not as detailed as the microsoftsite but it has a nice overview of all the things
and functions needed for coding for gecko (mozilla)
--------------------------------------------------
Camillah Ringes
Web Developer at Dynamic Zones
Manager at DMXzone.com
--------------------------------------------------
