473,569 Members | 3,009 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting IFRAME text

<iframe name="iframe" width="100%" height="25%" src="test1.txt" >
</iframe>

<a href="test1.txt " target="input"> one</a>
<a href="test2.txt " target="input"> two</a>

<form name="form1">
<textarea name="textarea" cols=80 rows=18>
This is a test
</textarea><br>
<button name="Copy" value="Copy" OnClick="DoCopy ()">Copy</button>
</form>

<script>

function DoCopy()
{
form1.textarea. value=iframe.in nerText;
}
</script>
Nov 10 '05 #1
15 20537
Whoops, forgot the question !

I want to copy the text from a text document opened in an iframe into a
textarea at th press of a button.
<iframe name="iframe" width="100%" height="25%" src="test1.txt" >
</iframe>

<a href="test1.txt " target="input"> one</a>
<a href="test2.txt " target="input"> two</a>

<form name="form1">
<textarea name="textarea" cols=80 rows=18>
This is a test
</textarea><br>
<button name="Copy" value="Copy" OnClick="DoCopy ()">Copy</button>
</form>

<script>

function DoCopy()
{
form1.textarea. value=iframe.in nerText;
}
</script>


I tried 'iframe.body.in nerText' but that did not work.

Aaron
Nov 10 '05 #2
VK

Aaron Gray wrote:
Whoops, forgot the question !

I want to copy the text from a text document opened in an iframe into a
textarea at th press of a button.
<iframe name="iframe" width="100%" height="25%" src="test1.txt" >
</iframe>

<a href="test1.txt " target="input"> one</a>
<a href="test2.txt " target="input"> two</a>

<form name="form1">
<textarea name="textarea" cols=80 rows=18>
This is a test
</textarea><br>
<button name="Copy" value="Copy" OnClick="DoCopy ()">Copy</button>
</form>

<script>

function DoCopy()
{
form1.textarea. value=iframe.in nerText;
}
</script>


I tried 'iframe.body.in nerText' but that did not work.

Aaron

<iframe name="iframe01" width="100%" height="25%" src="test1.txt" >
</iframe>

<form name="form1">
<textarea name="txt01" cols=80 rows=18>
This is a test
</textarea><br>
<button name="Copy" value="Copy" OnClick="DoCopy ()">Copy</button>
</form>
<script>
function DoCopy()
{
document.forms['form1'].elements['txt01'].value =
document.frames['iframe01'].document.body. innerHTML;
}
</script>

1) Never ever give the names/id using generic html element names
("iframe", "textarea" etc.)

2) <http://www.javascriptt oolbox.com/bestpractices/> see about
addressing frames/form elements - helps a lot.

;-)

Nov 10 '05 #3
> 1) Never ever give the names/id using generic html element names
("iframe", "textarea" etc.)
Okay :)
2) <http://www.javascriptt oolbox.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.

Aaron
Nov 10 '05 #4


Aaron Gray wrote:
<iframe name="iframe" width="100%" height="25%" src="test1.txt" >
</iframe>
Is that really a text/plain document in the iframe? Or a text/html
document? Obviously the DOM is defined for (structured) HTML and XML
documents but not for (unstructured) text documents.
Though some browser (IE, Mozilla too perhaps) might expose a document
with a body for text, see below.
<form name="form1">
<textarea name="textarea" cols=80 rows=18>
This is a test
</textarea><br>
<button name="Copy" value="Copy" OnClick="DoCopy ()">Copy</button>
<input type="button" value="Copy"
onclick="DoCopy (this.form.elem ents.textarea, 'iframe')">

function DoCopy()


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.val ue =
window.frames[iframeName].document.body. innerHTML;
}
}

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 10 '05 #5
> <input type="button" value="Copy"
onclick="DoCopy (this.form.elem ents.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.val ue =
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
Nov 10 '05 #6
Aaron Gray said the following on 11/10/2005 3:57 PM:
<input type="button" value="Copy"
onclick="DoCopy (this.form.elem ents.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.val ue =
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.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 10 '05 #7
>> 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
Nov 10 '05 #8
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.javascriptt oolbox.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 referenceToIfra me.document.bod y.firstChild.fi rstChild.nodeVa lue 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
Nov 10 '05 #9
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
Nov 10 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
10899
by: Lorenzo Vaina | last post by:
Can i get the content of an URL and put it in a variable using javascript? I want js execute different operations varying a file that is on internet. Thanks, regards.
5
2552
by: Noorul Ameen | last post by:
Dear Folks, In a HTML page I want to get all the files in a selected dirs. Is that any way to do this thru javascript. Help will be highly appreciated. Thanks in advance. Regards, Ameen T
9
11155
by: aatcbbtccctc | last post by:
Hi folks I've googled for an answer to this, with no success. Can someone please jump in, and put me out of my misery! (I'm sure it's quite simple) I have an invisible IFRAME, and a visible DIV: <IFRAME id=myframe style="display:none" src="..." onload="ShowNews(this)"></IFRAME>
4
2531
by: Drew | last post by:
This might beyond the scope of this group because it deals with SharePoint, but I'm not sure if I can't get it to work because of SharePoint or because JavaScript is weird (I don't have much experience with JavaScript). Anyway, here is the code i'm working with. Basically, it creates appends a hidden IFrame to the page, gets the links from...
4
5074
by: bushi | last post by:
hi! i'm designing a web application,basically it have two pages,"client_browser.apsx" & "adserver.aspx"."client_browser.aspx" contains an iframe,and in the iframe i have displayed my "adserver.aspx".now i want to get the URL path of the client browser on my "adserver.aspx".but the code i have used returns me the URL path of...
0
7765
by: tequilamala | last post by:
I have an Iframe in one of the pages i am developing... the iframe is suppose to scroll up and down and the links target the iframe. the problem is that the iframe scrolls side to side on internet explorer but not on firefox. I dont want it to scroll sideways. in index.htm the iframe is at the bottom of the code. index.htm <!DOCTYPE...
3
4389
by: smartphreak | last post by:
not sure if this is the right forum but i will try explain myself. lets start by giving the code <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>TITLE</title> <script type="text/javascript" src="loadiframes.js"></script> <style type="text/css"> body {
6
4102
by: buntyindia | last post by:
Hi, I have a page. There is a section 'sidebar' where bulleted text is there. Just after first bullet there is a hidden IFRAME. That go visible on clicking of that bullet text. My problem is with Safari Browser in Mac and WindowsXP. When we press the tab after first bullet link instead of going to next bulleted text the focus goes to the...
0
7619
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7930
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7681
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5228
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
950
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.