dongniaoli1822 2014-07-28 11:11
浏览 48

HTML:从特定iframe本身的文档中设置iframe属性

I have a html document as below. I want to change certain attributes of the "title iframe from the document present inside my title ifame html documet. But I am not able to change the iframe property from my title.php code which is present inside the titleFrame iframe. How can I do this?

<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>

Inside src/title.php File:

<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;
        }

    ?>
  • 写回答

1条回答 默认 最新

  • dpf7891 2014-07-29 05:33
    关注

    The below javascript code worked for changing the parent iframe properties.

    echo "window.parent.document.getElementById('titleFrame').style.height='70px'; ";
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大