你运行到17行,b.html还没加载呢,就获取不到了
解决方案 »
- js怎么过滤特定符号
- 请问字符串中有连接符&怎么处理 带演示网址
- |zyciis| Jquery Ajax如何捕捉我的ASP.NET的出错信息,如:throw new Exception("测试错误");
- 关于网页合成图片的问题,类似于qq秀
- 请高人写一个二级连动的下拉列表并计算结果 出100分
- 请问JavaScript中报"undefined示定义"是何原因
- 求助!
- 200分求 JAVASCRIPT的WEB在线编辑器!
- 表单JS 的问题
- 请问在JS中可以用什么代码代替AS3中的writeUTFBytes、writeInt与position命令?
- 用js做了一个cookie显示用户访问记录,火狐显示没问题,ie显示异常
- jQuery执行现在文件的请求,用什么方法
2.是button.onclick=function(),不是button.click=function()
<!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=utf-8" />
<title>a</title>
<script type="text/javascript">
function alert_(){
var iframe=document.getElementById("frame").contentWindow;
alert(iframe.document.getElementById("div").innerHTML);
}
function update_(){
var iframe=document.getElementById("frame").contentWindow;
iframe.document.getElementById("div").innerHTML="七上八下";
}
function doit(){
//给b页面绑定点击事件 这里为什么不行呢 求解决
var button=document.getElementById("frame").contentWindow.document.getElementById("button2");
button.onclick=function(){
alert("555555555");
}
}
</script>
</head>
<body onload="doit()">
<div>
<input type="button" value="弹出iframe中div的值" onclick="alert_()" id="button1"/>
<input type="button" value="修改iframe中div的值" onclick="update_()"/>
</div>
<iframe src="b.html" frameborder="1" width="600" height="100" style="border:#F00" id="frame"/>
</body>
</html>
<iframe src="b.html" frameborder="1" width="600" height="100" style="border:#F00" id="frame"/>
<script type="text/javascript">
var button=document.getElementById("frame").contentWindow.document.getElementById("button2");
button.onclick=function(){
alert("555555555");
}
</script></body>