訓練家的快寫筆記

The legend of trainer's paper


搜尋:

     關閉     
標題:iframe 的操作
內容:

$("iframe").eq(0).contents().find('#selector')

 var newtemp=sprintf("<div style='margin:50px;'>%s</div>",$("#a")[0].contentWindow.document.body.innerHTML);
  $("#a")[0].contentWindow.document.body.innerHTML=newtemp;
  $("#a")[0].setAttribute('height',$("#a")[0].contentWindow.document.body.scrollHeight+'px');

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
html,body{
 width:100%;
 height:100%;
 margin:0px;
}
</style>
<script language="javascript">
system_include('jquery-1.4.2.min');
system_include('php.default.min.js');
function a()
{
  alert(window.frames[0].innerHeight);
  alert($("#a")[0].contentWindow.document.body.scrollHeight);


  var temp=$("#a")[0].contentWindow.document.body.innerHTML;

  var newtemp=sprintf("<div style='margin:50px;'>%s</div>",$("#a")[0].contentWindow.document.body.innerHTML);
  $("#a")[0].contentWindow.document.body.innerHTML=newtemp;
  $("#a")[0].setAttribute('height',$("#a")[0].contentWindow.document.body.scrollHeight+'px');
}

$(document).ready(function(){
  alert(print_r(window.frames[0],true));
  alert(window.frames[0].innerHeight);
  $("#a")[0].setAttribute('height',window.frames[0].innerHeight+'px');

$('#iframepage').contents().find("#iframeElement");
});
</script>

</head>
<body>

<input type="button" onClick="a();" value="check">
<iframe id="a" src="a/a.htm" scrolling="yes" style="width:100%;display:none;" onload="a();$('#a').show();"></iframe>


</body>
</html>