我有一个html文档如下。我想从我的标题ifame html documet中的文档中更改"标题iframe的某些属性。但我无法从titleFrame iframe中出现的title.php代码更改iframe属性。我怎么能这样做?
<style>
iframe
{
width: 100%;
border: 0;
}
#titleFrame
{
position: absolute;
height: 100%;
top: 0;
left: 0;
background-color: red;
}
</style>
<body>
<div class='myDiv'> </div>
<img class='myImg' src='image.jpg' />
<iframe src="src/title.php" id="titleFrame" name="titleFrame" scrolling="No" noresize="noresize" title="title" />
<iframe src="" id="mainFrame" name="mainFrame" scrolling="Auto" title="mainFrame" />
</body>
<div class="titleDiv">
<span class='titleText'> Resource Management </span>
<span id='userNameDisp'> </span>
<input id='theTime' type=text value='' size=35 />
</div>
<?php
if(session_id() == '')
session_start();
if(isset($_SESSION['userName']))
{
echo "<script> ";
echo "$(\"#userNameDisp\").html(\"Welcome \"+\"".$_SESSION['userName']."<br/><span class='logOutClass'><a href='logout.php' target='mainFrame'> Logout </a> </span>\"); ";
echo "window.parent.document.getElementById('titleFrame').css('height','70px'); ";
echo "$('#titleFrame').css('background-color','#EFEFEF'); ";
echo "window.parent.document.getElementById('mainFrame').setAttribute('src','src/home.php'); ";
echo "</script></body> </html>";
return;
}
?>
答案 0 :(得分:0)
以下javascript代码用于更改父iframe属性。
echo "window.parent.document.getElementById('titleFrame').style.height='70px'; ";