已经取得
function getDoc(){
var doc = document.body.getElementsByTagName("iframe");
for(var i=0;i<doc.length;i++){
if(doc[i].src.indexOf('fuyou001')>-1){
if (document.all){
return doc = doc[i].document;
}else{
return doc = doc[i].contentDocument;
}
};
} }
var obj = getDoc();
为什么obj.getElementById('mail')返回是null 但明明有mail这个id的
function getDoc(){
var doc = document.body.getElementsByTagName("iframe");
for(var i=0;i<doc.length;i++){
if(doc[i].src.indexOf('fuyou001')>-1){
if (document.all){
return doc = doc[i].document;
}else{
return doc = doc[i].contentDocument;
}
};
} }
var obj = getDoc();
为什么obj.getElementById('mail')返回是null 但明明有mail这个id的
解决方案 »
- 验证URL的正则表达式
- 急求,settimeout和setInterval怎么一起用?
- javascript如何获取flash的加载进度
- 提问一下关于单击以激活和使用此控制的问题
- 关于JS重载的问题
- 如何在javascript里更改调用的函数?
- 同页面从表单传值给框架的问题!!~~~~急,在线等!!!
- 一个JS数组的问题!诚心求教!在线等,谢谢!
- (javascript)如何在一个页面中捕捉到键盘事件?
- ajaxFileUpload上传文件报错SecurityError: Blocked a frame with origin from
- 利用Js动态添加Html元素,无法在源代码看到结果
- oblur事件 兼容问题
var doc = document.body.getElementsByTagName("iframe");
for(var i=0;i <doc.length;i++){
if(doc[i].src.indexOf('fuyou001')>-1){
return doc = doc[i].contentWindow.document;
}
}
}
var obj;
window.onload(){
obj = getDoc();
alert(obj.getElementById('mail'));
}
firfox 下报
<file://> à³CPÎ <http://hud.zhulang.com> ûÖ^' Window.document
getDoc()union_ad.php.htm (第 165 行)
pre()union_ad.php.htm (第 136 行)
[Break on this error] return doc = doc[i].contentWindow.document; \r\n
还有上面那个在ie下能用吗
应该返回来了,才对啊
<!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" />
</head>
<body onload="aa()">
<iframe name="aaaaa" src='test.html' ></iframe>
<script language="javascript" type="text/javascript">
function getDoc(){
var doc = document.frames ;
for(var i=0;i <doc.length;i++){
if(document.all){
return doc[i].window.document;
}else{
return doc[i].contentDocument;
}
}
}
function aa(){
obj = getDoc();
alert(obj.getElementById('mail').value);
}</script>
</body>
</html>
这个在ie下会报错Error :缺少对象
Char:13
Code:0
Error:'window.document' 为空或不是对象
function getDoc(){
var doc = document.body.getElementsByTagName("iframe");
for(var i=0;i <doc.length;i++){
if(doc[i].src.indexOf('test1')>-1){
return doc = doc[i].contentWindow.document;
}
}
}
var obj;
window.onload=function(){
obj = getDoc();
alert(obj.getElementById("mail").innerHTML);
}
</script>
<iframe src="test1.asp?x"></iframe>
test1.asp<div id="mail">xxaxxx</div>
就上面的网址,哪位能取出id 为mail 的object
我这里是var doc = document.frames ;获得的frame集合
不是 你上面的var doc = document.body.getElementsByTagName("iframe");
用 你的获得frame集合地方法 就报 'window.document' 为空或不是对象
有什么办法可以取 这个贴子都是为了取出id 为email 的object 对象 的发的
return doc = doc[i].contentWindow.document; //FF中使用