获取IFRAME文本 [英] Getting IFRAME text

查看:79
本文介绍了获取IFRAME文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< iframe name =" iframe"宽度= QUOT; 100%QUOT;高度= QUOT; 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行= 18>

这是一个测试

< / textarea>< br>

< button name =" ;复制与QUOT;值= QUOT;复制和QUOT; OnClick =" DoCopy()">复制< / button>

< / form>


< script>


函数DoCopy()

{

form1.textarea.value = iframe.innerText;

}

< / script>

解决方案

糟糕,忘记了问题!


我想要通过按钮将文本从iframe中打开的文本文本复制到

textarea。

< iframe name ="的iframe"宽度= QUOT; 100%QUOT;高度= QUOT; 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行= 18>
这是一个测试
< / textarea>< br>
< button name ="复制"值= QUOT;复制和QUOT; OnClick =" DoCopy()">复制< / button>
< / form>

< script>

函数DoCopy()
{
form1.textarea.value = iframe.innerText;
}
< / script>




我试过''iframe.body.innerText''但是没有用。


Aaron




Aaron Gray写道:

哎呀,忘记了这个问题!

我想把iframe中打开的文本文档中的文本复制到
textarea中按下按钮。

< iframe name =" iframe"宽度= QUOT; 100%QUOT;高度= QUOT; 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行= 18>
这是一个测试
< / textarea>< br>
< button name ="复制"值= QUOT;复制和QUOT; OnClick =" DoCopy()">复制< / button>
< / form>

< script>

函数DoCopy()
{
form1.textarea.value = iframe.innerText;
}
< / script>



我试过''iframe。 body.innerText''但是没有用。

Aaron



< iframe name =" iframe01"宽度= QUOT; 100%QUOT;高度= QUOT; 25%" src =" test1.txt">

< / iframe>


< form name =" form1">

< textarea name =" txt01" cols = 80行= 18>

这是一个测试

< / textarea>< br>

< button name =" ;复制与QUOT;值= QUOT;复制和QUOT; OnClick =" DoCopy()">复制< / button>

< / form>

< script>

功能DoCopy()

{

document.forms [''form1'']。elements [''txt01'']。value =

document.frames [''iframe01'']。document.body.innerHTML;

}

< / script>


)永远不要使用通用的html元素名称给出名称/ id

(iframe,textarea等)


2) < HTTP://www.javascripttoolbox.com/bestpractices/>看看

寻址框架/表格元素 - 帮助很大。


;-)

> 1)永远不要使用通用的html元素名称给出名字/ id

(iframe,textarea等)


好​​的:)

2)< http://www.javascripttoolbox.com/bestpractices/>看看
寻址框架/表单元素 - 帮助很大。




这不涉及从iframe中的文本文档中获取文本

这就是我追求的目标。


Aaron


<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.innerText;
}
</script>

解决方案

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.innerText;
}
</script>



I tried ''iframe.body.innerText'' but that did not work.

Aaron



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.innerText;
}
</script>



I tried ''iframe.body.innerText'' 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.javascripttoolbox.com/bestpractices/> see about
addressing frames/form elements - helps a lot.

;-)


> 1) Never ever give the names/id using generic html element names

("iframe", "textarea" etc.)
Okay :)
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.

Aaron


这篇关于获取IFRAME文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆