From: Aaron Gray on 10 Nov 2005 15:57 > <input type="button" value="Copy" > onclick="DoCopy(this.form.elements.textarea, 'iframe')"> > > function DoCopy (textControl, iframeName) { > if (window.frames && window.frames[iframeName] && > window.frames[iframeName].document && > window.frames[iframeName].document.body && > window.frames[iframeName].document.body.innerHTML) > { > textControl.value = > window.frames[iframeName].document.body.innerHTML; > } > } > Great, the text appears as a <pre> block, but using InnerText rather than innerHTML sorts that out and just copies the raw text :) Thanks alot, Aaron
From: Randy Webb on 10 Nov 2005 16:59 Aaron Gray said the following on 11/10/2005 3:57 PM: >> <input type="button" value="Copy" >> onclick="DoCopy(this.form.elements.textarea, 'iframe')"> >> >> function DoCopy (textControl, iframeName) { >> if (window.frames && window.frames[iframeName] && >> window.frames[iframeName].document && >> window.frames[iframeName].document.body && >> window.frames[iframeName].document.body.innerHTML) >> { >> textControl.value = >> window.frames[iframeName].document.body.innerHTML; >> } >> } >> > > > Great, the text appears as a <pre> block, but using InnerText rather than > innerHTML sorts that out and just copies the raw text :) And only works in IE since innerText is IE proprietary code. -- Randy comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
From: Aaron Gray on 10 Nov 2005 18:02 >> Great, the text appears as a <pre> block, but using InnerText rather than >> innerHTML sorts that out and just copies the raw text :) > > And only works in IE since innerText is IE proprietary code. Okay, I will have to do a workaround at some point :( Aaron
From: Thomas 'PointedEars' Lahn on 10 Nov 2005 18:45 Aaron Gray wrote: >> 1) Never ever give the names/id using generic html element names >> ("iframe", "textarea" etc.) > > Okay :) Don't listen to what V'often wrong'K is telling you. There is nothing wrong in using such names, there is no known side effect in any language or UA. What is true is that it is a Good Thing to choose names with meaning; for example, the `textarea' element could be named according to its expected content. >> 2) <http://www.javascripttoolbox.com/bestpractices/> see about >> addressing frames/form elements - helps a lot. > > This does not deal with getting the text from a text document > in an iframe which is what I was after. Try referenceToIframe.document.body.firstChild.firstChild.nodeValue in Mozilla/5.0. WFM in Firefox 1.0.7/Linux as an iframe with a plaintext resource is made available through an embedded HTML document with a `pre' element containing the resource's content. PointedEars
From: Thomas 'PointedEars' Lahn on 10 Nov 2005 18:46 Aaron Gray wrote: > Great, the text appears as a <pre> block, but using InnerText rather than > innerHTML sorts that out and just copies the raw text :) Note that innerText (JS is case-sensitive) is an IE-proprietary property. PointedEars
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: How to call a js file from another js file? Next: How to rotate the image |