iframe的一些小操作
阿新 • • 發佈:2018-12-31
eg:
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="/statics/js/jquery.min.js"></script>
</head>
<iframe src="http://www.myztgl.com/2018/kaoyan/testFeature/index.html" height="100%" width="100%" frameborder="0" id="myiframe" name="child"></iframe>
</html>
獲取當前url資訊:
父頁面:var url = window.location.search;
子頁面:var hostUrl = window.parent.location.search;
調取分別的js的function:
父頁面調取子頁面:child.window.editChildTDK( )(child是iframe的name,editChildTDK是子頁面的function)
子頁面調取父頁面:window.parent.submitForm();(submitForm是父頁面的function)
修改當前頁面TDK:
//title
document.title = "修改模板";
//key+description
var metas = document.getElementsByTagName("meta");
metas.description.content = keys;
metas.keywords.content = descriptions;
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="/statics/js/jquery.min.js"></script>
</head>
<iframe src="http://www.myztgl.com/2018/kaoyan/testFeature/index.html" height="100%" width="100%" frameborder="0" id="myiframe" name="child"></iframe>
</html>
獲取當前url資訊:
父頁面:var url = window.location.search;
子頁面:var hostUrl = window.parent.location.search;
調取分別的js的function:
父頁面調取子頁面:child.window.editChildTDK( )(child是iframe的name,editChildTDK是子頁面的function)
子頁面調取父頁面:window.parent.submitForm();(submitForm是父頁面的function)
//title
document.title = "修改模板";
//key+description
var metas = document.getElementsByTagName("meta");
metas.description.content = keys;
metas.keywords.content = descriptions;