如何让iframe里弹出的层显示在整个网页上

2024-10-12 03:05:46

1、在文件夹中创建两个文件,一个iframe页面,一个父页面index。

如何让iframe里弹出的层显示在整个网页上

3、打开iframe页面,里面添加一个按钮。

如何让iframe里弹出的层显示在整个网页上

5、现在我们对iframe做修改,在button上监听onclick调用“show”方法,通过show动态在父页面body中创建一个div层并显示出来,把这个层style中的position:absolute,z-index设置足够大就会显示在顶层。function show() { var showdiv=document.createElement('div'); showdiv.setAttribute('id','topdiv'); showdiv.setAttribute("style",'position:absolute;z-index:999;width:300px;height:300px;'); var tt=document.createTextNode('我是iframe弹出层'); window.parent.document.body.appendChild(showdiv).appendChild(tt);}

如何让iframe里弹出的层显示在整个网页上
猜你喜欢