一个index.html,一个iframe.html,但是要注意,html文件必须放到服务器下访问,file协议下无法生效的。
1.普通需求:只需要子页面获取父页面元素
window.parent或者参考window.iframe用法,比较简单
2.霸气需求,drag拖动跨ifame(老式的mousedown + mousemove + mouseup模拟的drag事件无法实现)
这里借助HTML5中的drag and drop API
index.html
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="/pfl/vendor/jquery.min.js"></script>
<style>
.trash{
padding: 10px;
height: 100px;
background: #BCDAFA;
border: 2px solid #8C96FF;
font-size: 60px;
line-height: 100px;
}
.trash.hover{
background: #FFFFAB;
border: 2px dashed red;
color: red;
}
#iframe{width:100%;height:450px;}
</style>
</head>
<body&g