<html>
<head>
<script type="text/javascript">
function fff()
{
var str=document.getElementById("dd").document.getElementById("dddd").innerHTML;
alert(str);
}
</script>
</head>
<body>
<iframe id="dd" src="2.html" ></iframe><a href="#" onclick="fff()">下看一下</a>
</body>
</html>
这样为什么不行
<head>
<script type="text/javascript">
function fff()
{
var str=document.getElementById("dd").document.getElementById("dddd").innerHTML;
alert(str);
}
</script>
</head>
<body>
<iframe id="dd" src="2.html" ></iframe><a href="#" onclick="fff()">下看一下</a>
</body>
</html>
这样为什么不行
window.frames[iframeID].document.getElementById(textareaID).innerText;
其中iframeID为iframe的id或序号,textareaID为textarea的id
我是ff用户
<head>
<script type="text/javascript">
function fff()
{
var str=document.frames("dd").document.getElementById("dddd").value
alert(str);
}
</script>
</head>
<body>
<div align="center">
<a href="#" onclick="fff()">下看一下 </a> <br/>
<iframe id="dd" name="dd" src="2.html" ></iframe>
</div>
</body>
</html><html>
<head>
<script type="text/javascript">
function fff()
{
var str=document.frames("dd").document.getElementById("dddd").value
alert(str);
}
</script>
</head>
<body>
<div align="center">
<a href="#" onclick="fff()">下看一下 </a> <br/>
<iframe id="dd" name="dd" src="2.html" ></iframe>
</div>
</body>
</html>代码在上面自己看下了。
<head>
<script type="text/javascript">
function fff()
{
var str=document.frames("dd").document.getElementById("dddd").value;
alert(str);
}
</script>
</head>
<body>
<div align="center">
<a href="#" onclick="fff()">下看一下 </a> <br/>
<iframe id="dd" name="dd" src="2.html" > </iframe>
</div>
</body>
</html>
--------------------------2.html
<html>
<head>
</head>
<body>
<div align="center">
<input type=text id=dddd value='555555'></input>
</div>
</body>
</html>
如果需要进行页面交互,须转换思路使用iframe内部页面中脚本来控制外部页面元素
var str = document.getElementById("dd").contentWindow.document.getElementById("dddd").innerHTML;