如何使用javascript向父iframe提供z索引
使用javascript为如何使用javascript向父iframe提供z索引,javascript,php,jquery,iframe,Javascript,Php,Jquery,Iframe,使用javascript为iframe设置z索引时出现问题 我在一个js文件(test.js)中创建了一个iframe,并给出了一个z-index:0。在iframe的src中加载了一个php页面(code.php) 在该php文件中包含另一个js文件(ad.js) 在该js文件中,我又创建了两个iframe。加载该js时,我试图在test.js中获取父级iframe的ID,但结果出错 我想在ad.js内将外部iframez-index值设置为1 test.js中使用的代码 ifrm = doc
iframe
设置z索引时出现问题
我在一个js文件(test.js)中创建了一个iframe
,并给出了一个z-index:0
。在iframe
的src
中加载了一个php页面(code.php)
在该php文件中包含另一个js文件(ad.js)
在该js文件中,我又创建了两个iframe
。加载该js时,我试图在test.js中获取父级iframe
的ID,但结果出错
我想在ad.js内将外部iframe
z-index
值设置为1
test.js中使用的代码
ifrm = document.createElement("IFRAME");
ifrm.id='ifrm_AS_Outer';
ifrm.name='ifrm_AS_Outer';
ifrm.setAttribute("src", "http://www.fsdfsdfsdf.com/en/code.php?campaignid="+campaignid+"&publisherid="+publisherid+"&width="+width+"&height="+height+"&camp_id="+camp_id+"&host="+host+"&url="+b);
ifrm.setAttribute("scrolling", "no");
ifrm.style.width ='100%';
ifrm.style.height = '100%';
ifrm.style.position = "fixed";
ifrm.style.zIndex=0;
在Code.php中
echo '<script src="ad.js"></script>';
echo '<script>var id= "'.$valurl.'";</script>';
但是创建类型错误“TypeError:document.getElementById(…)为空”
任何人都请帮帮我 如果没有任何代码或HTML,很难理解您试图执行的操作。如果您的iframe是不同的域,则浏览器中的“同源”安全限制将阻止从一个iframe访问另一个iframe。此外,iframe是不同的文档。因此,您不能使用自己的文档在父框架中查找内容。它们根本不在那个文档中。搜索iframe时,必须获取该特定iframe的文档。
document.getElementById('ifrm_AS_Outer').style.zIndex= '1';