Skip to content

Commit

Permalink
去除iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
K-walker committed Sep 12, 2017
1 parent ef4c20c commit ee51a77
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 73 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 忽略 .idea 文件夹
/.idea/

167 changes: 98 additions & 69 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion css/frame.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
transition:width .5s , top .5s , left .5s;
}

.container iframe {
.container .mypage {
width: 100%;
height: 100%;
}
Expand Down
1 change: 1 addition & 0 deletions frame.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
</div>
</div>
<script src="js/jquery-1.8.1.min.js"></script>
<script src="js/DIVembed.js"></script>
<script src="js/underscore.js"></script>
<script src="js/mousewheel.js"></script>
<script src="js/frame.js"></script>
Expand Down
6 changes: 6 additions & 0 deletions home.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,11 @@
</head>
<body>
<h1>首页</h1>
<script src="./js/jquery-1.8.1.min.js"></script>
<script>
$(document).ready(function () {
$('h1').css("color",'red');
})
</script>
</body>
</html>
21 changes: 21 additions & 0 deletions js/DIVembed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Created by 004928 on 2017/7/10.
*/
/**
* 加载Html
* @param containerId 容器id
* @param filePath 文件路径
* @param cb 加载完成后的回调 文件路径
*/
function loadPage (containerId , filePath , cb) {
if(typeof window.$ === 'undefined' || window.$ == null) throw "请先引入jq";
$.ajax({
url: filePath ,
type:'GET',
dataType:'html',
success:function (data) {
$(containerId).html(data);
if(cb) {cb();}
}
})
}
9 changes: 6 additions & 3 deletions js/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,16 @@
* @param path
*/
function createTabPage (id , path) {
var page = $("<iframe class='myframe' id='iframe"+id+"' name='iframe' border='0' frameborder='0' src='"+path+"'></iframe>");
//var page = $("<iframe class='mypage' id='iframe"+id+"' name='iframe' border='0' frameborder='0' src='"+path+"'></iframe>");
var page = $("<div class='mypage' id='page"+id+"' ></div>");
if(currPage != null) {
currPage.addClass('hide');
}
$(".container").append(page);
page.removeClass('hide');
currPage = page ;
// 加载目标网页
window.loadPage(page[0] , path);
}

/**
Expand All @@ -295,7 +298,7 @@
*/
function switchPage (id) {
currPage.addClass('hide');
currPage = $("#iframe"+id).removeClass('hide');
currPage = $("#page"+id).removeClass('hide');
}

/**
Expand All @@ -305,7 +308,7 @@
*/
function closePage (id , tab) {
$(tab).closest(".tab").remove();
$("#iframe"+id).remove();
$("#page"+id).remove();
}

/**
Expand Down

0 comments on commit ee51a77

Please sign in to comment.