Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

toggle between rte and regular edit.

Status
Not open for further replies.

vasah20

Programmer
Feb 16, 2001
559
0
0
US
Hi -
I'm having a problem with formatting between RTE and just regular editing, within an IFRAME. Currently, in a doc called rteparent.htm, what I'm doing is generating the IFRAME with a blank document inside, which is for the straight text editing. Upon clicking the 'toggle RTE' link, I change iframe.location.href to the page containing the rte code (rte/rtechild.htm). In order to transmit the data between the child and the parent, i've set up a form on the parent that has a hidden field, then from inside rtechild I reference opener.formname.formfield.value. Unfortunately, when i do this i also lose the abilty to wrap any text that the user types in. While this isn't too big a deal, it leads to some issues when they try to scroll horizontally. Is there anything I can do about this?

Here's the JS code i'm using to toggle the rte on and off:
Code:
rteparent.htm

/*function: toggleRTE
 *@params: elt - IFRAME name
 *@returns: none
 * - switches on and off the RTE editing. Retains all content when switching to and from
 */
function toggleRTE(elt) {
	var contents;	//for the HTML content, making sure to strip out a xmp mark.
	var target = frame[elt];	 //make life easier

	if (target.location.href.match(/dpg\.asp/gi)) {	
		contents  = frame(target.name).document.body.innerHTML;
//		contents = contents.replace(/<\s*\/xmp>\s*<\s*xmp\s*>/gi,&quot;<br><br>&quot;);	//format it a little bit to maintain consistency
//		contents = contents.replace(/\n/gi,&quot;<br>&quot;);
//		contents = contents.replace(/<\s*xmp\s*>|<\s*\/\s*xmp\s*>/gi,&quot; &quot;);

		form.tempHolder.value = contents;
		eval(&quot;form.h&quot; + target.name + &quot;.value = &quot; + target.name + &quot;.document.body.innerText;&quot;);	//get stuff already there
		target.location.replace(&quot;rte/rtechild.htm&quot;);
		frame(target.name).document.designMode = &quot;Off&quot;;	//since the IFRAME handles everything else

	} else {
		target.location.replace(&quot;&quot;);
		contents = frame(target.name).document.frames[0].document.body.innerHTML;
//		contents = contents.replace(/<br>/gi,&quot;\n&quot;);
//		contents = contents.replace(/<\/?p>/gi,&quot;\n\n&quot;);

		form.tempHolder.value = contents;
		frame(target.name).document.open();
//		frame(target.name).document.write(&quot;<xmp>&quot; + form.tempHolder.value + &quot;</xmp>&quot;);
		frame(target.name).document.write(form.tempHolder.value);
		frame(target.name).document.close();
		frame(target.name).document.designMode = &quot;On&quot;;
	} //end if
} //end toggleRTE

TIA leo

------------
Leo Mendoza
lmendoza@garbersoft.net
 
Rather than use a form element in the parent window to store the value, why don't you create a function in the parent window and call it. That way you could store the information however you want (i.e. string, array, object). You could then call the function from the child and send in what you want as parameters.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top