网页开发中调用iframe中的函数或者是dom元素

iframe中的代码

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>By DragonDean</title>
<script>
function ziti(zt){
    alert('你成功调用了DragonDean写的函数了!');
}
</script>
</head>

<body>
    this is a dragondean's test page !
</body>
</html>

 

调用iframe中的ziti()函数

window.frames[0].ziti();

获取iframe中body的代码

$("iframe").contents().find('body').html()

就做个记录,怕以后又遇到同样的问题还得到处找资料。更伤心的是网上好多资料是不可靠的。

posted @ 2014-11-03 22:03  DragonDean  阅读(390)  评论(0编辑  收藏  举报
CopyRight (C) 2014 By:DreagonDean 小程序公众号开发交流群:294322801