如何取得iframe里面的内容,需跨域。
比如<iframe src='http://www.qq.com'></iframe>
比如<iframe src='http://www.qq.com'></iframe>
解决方案 »
- wuyq11 加分
- 请教大师们,Databinder.Eval 得不到任何值(空字符串?),也不出错,为什么?
- MultiLine的TextBox不能保存换行符?
- 帮忙解决一下简单的实现!
- URL里面的Querystring的问题
- 急 关于word文件写入和读取数据库的问题
- 倾号荡分求SP开发资料或相关文档!
- 附件显示的一个问题
- 把word文档上传到服务器之后,怎么让用户下载和打开浏览!
- Response.WriteFile("\\\\10.88.60.98\\d$\\yubo\\index.html");读取之后可以修改吗?
- web项目能否实现多个实例?不同的客户访问不同的数据库?
- 登录成功后怎么返回登录前的页面
iframe_ID.iframe_document_object.object_attribute = attribute_value
例子
onClick="iframe_text.myH1.innerText='http://www.pint.com';"
子窗口调用父窗口
parent.parent_document_object.object_attribute = attribute_value
例子
onclick="parent.myH1.innerText='http://www.pint.com';" 上面在IE下没有问题,但在firefox下不正常。在firefox下,应该是
父窗口调用子窗口
window.frames["iframe_ID"].document.getElementById("iframe_document_object").object_attribute = attribute_value
例子
window.frames["iframe_text"].document.getElementById("myH1").innerHTML= "http://www.pint.com";
子窗口调用父窗口
parent.document.getElementById("parent_document_object").object_attribute = attribute_value
例子
parent.document.getElementById("myH1").innerHTML = "http://www.adsf.com"; test.htm里面firefox下访问iframe 必须用name,不能用id
所以要改为name="iframe_test" 完整的例子
test.htm<HTML>
<HEAD>
<TITLE> Test Page </TITLE>
<script src="prototype-1.4.0.js"></script>
<script language="javascript">
function show(){
window.frames["iframe_text"].document.getElementById("myH1").innerHTML
= "http://www.pint.com"; }
</script>
</HEAD>
<BODY>
<iframe height="350" width="600" src="iframe_text.htm"
name="iframe_text"></iframe>
<form action="" method="post">
<input name="haha" id="haha" type="text" maxlength="30" value="haha"
/><br />
<textarea cols="50" rows="5" id="getAttributeMethod"></textarea>
<input type="button" onClick="show();" value="提交"/>
</form>
<h1 id="myH1">d</h1>
</BODY>
</HTML> frame_test.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language="javascript">
function show(){
parent.document.getElementById("myH1").innerHTML =
"http://www.adsf.com"; } </script>
<body>
<h1 id="myH1">ha</h1>
<form action="" method="post">
<input name="abc" id="abc" type="text" maxlength="30" value="abc" /><br
/>
<textarea cols="50" rows="10" id="text"></textarea> <br />
<input type="button" value="提交" onclick="show();"/>
</form>
</body>
</html>