重点是这句话window.parent.closeIframe();
因为iframe和它的父页面谁也不知道谁。不能直接找到他的父页面的div,所以用window.parent找到iframe的父页面,然后在用父页面上的js 来关闭包裹iframe的div
<!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>无标题文档</title>
<script type="text/javascript" src="jquery-1.3.2.js"></script>
<script type="text/javascript">
$(function(){
$(".close").click(function(){
alert("本页上的close");
$("#win2").hide();
})
})
function closeIframe(){
alert("iframe里的close调用本函数");
$("#win2").hide();
}
</script>
</head>
<body>
<div id="win2" style=" width:300px; height:200px; border:1px solid red;">
<iframe style="height:182px; width:300px;" src="1.html"></iframe>
<a class="close">关闭本页div</a>
</div>
</body>
</html>
<!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>无标题文档</title>
<script>
function closeParent(){
window.parent.closeIframe();58
}
</script>
</head>
<body>
nihao
<a class="close" onclick="closeParent ()">关系iframe外层的div</a>
</body>
</html>
分享到:
相关推荐
最近在做作业中需要在不用iframe的情况下嵌套页面,所以只好在div中嵌套,用的是jquery方法。 复制代码代码如下: [removed] $(document).ready(function() { $(“#button”).click(function() { $(“#content”)....
部分代码如下: ...<body><div id="rbbox"><a class="button" onclick="closeBox()">关闭</a><iframe src="1.jpg" height="200" width="300" scrolling="no" ></iframe></div> </body> </html> ...
<input type="button" value="普通弹出窗口" onclick="ymPrompt.win('<div class=\'myContent\'>普通弹出窗口</div>',300,200,'普通弹窗测试')" /> 示例: 源码: <input type="button" value="iframe弹出窗口" ...
-修正了使用IFrame的Window关闭后不能再次打开的BUG(feedback:alexa99)。 -修正了IE下Grid中的一个JS问题(feedback:lqm4108)。 -修正Alert消息中引号未编码导致的JS错误(feedback:sun1299shine)。 +集成extjs...
网易编辑器用法演示 ; charset=gb2312" /> 网易编辑器用法演示 body{font-size:12px;color:#333333;...<input type="button" value="查看隐藏表单的内容" onClick="alert(content.value);"> </html>
好玩的登录页面<!...<!...documentation">...login"><div class="hand"></div><div class="hand hand-r"></div><div class="arms"><div class="arm"></div><div class="arm arm-r"></div></div></div><div class="pad">...
-修正了使用IFrame的Window关闭后不能再次打开的BUG(feedback:alexa99)。 -修正了IE下Grid中的一个JS问题(feedback:lqm4108)。 -修正Alert消息中引号未编码导致的JS错误(feedback:sun1299shine)。 +集成extjs...
<!...<... <head> <meta charset="utf-8">...link href ="gogo.css" type="text/css" rel =... <button><a href="index.html">Again</a></button> </form> </div> </body> </html>
<input type=button value=整理收藏夹 onclick="window.external.ShowBrowserUI("OrganizeFavorites", null)"> <input type=button value=语言设置 onclick="window.external.ShowBrowserUI("LanguageDialog", null...
<!...<... ... <div data-type="bar" clstag="h|keycount|cebianlan_h_jimi|btn" class="J-trigger jdm-toolbar-tab jdm-tbar-tab-jimi" data-name="jimi" data-login="true" data-iframe="//jimi.jd....
显示框架内的指定位置 <div u00a0style=’width:300px;height:300px;’><iframe src=’http://163.com’ style=’margin:-100px;width:100%;height:100%’></iframe></div> 改变文本框的属性(确定...
一、使用iframe,通过[removed]产生历史 代码如下: <!DOCTYPE html> <html> <head> <meta charset=”utf-8″/> <title>0</title> </head> <body> <input type=”...
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,dl,dt,dd,ol,nav...
<input name="cmdHelp" type="button" value="使用帮助" id="butn" onclick="alert('输入你的网址,例:www.iwbuy.com,输入关键词,例:无为搜索,选择查询页数,选择要查询的搜索引擎\n因为信息量太大等原因,目前只...
body,div,q,iframe,form,h5{ margin: 0; padding: 0;} img,fieldset { border: none 0; } body,td,textarea { word-break: break-all; word-wrap: break-word; line-height:1.5;} body,input,textarea,select,button...
<div class=uploadFile> <span id=doc><input type=text disabled=disabled /> <input type=hidden id=hidFileName /> <input type=button id=btnUploadFile value=上传 /> <input type=...
作用:包裹文本,并处理文本的表现形式 2、块级元素 每个元素独占一行显示的,称为 "块级元素" div,p,h1,h2,h3,h4,h5,h6 作用:布局 注意: 1、p标记不能嵌套其它的块级元素 2、行内元素中 最好 不要嵌套...
<div class=uploadFile> <span id=doc><input type=text disabled=disabled /> <input type=hidden id=hidFileName /> <input type=button id=btnUploadFile value=上传 /> <input type=...
可变元素(根据上下文语境决定该元素为块元素或者内联元素):button、iframe、script、del等 块级元素会独占一行,其宽度自动填满其父元素宽度;行内元素不会独占一行,相邻的行内元素会排列在同一行里,知道一行排...
7.3.4 表格内文字与边框的间距 ——cellpadding 131 7.4 设置表格背景 132 7.4.1 表格的背景颜色——bgcolor 132 7.4.2 表格的背景图像——background 133 7.5 设置表格的行属性 134 7.5.1 高度...