您的位置:首页 > Web前端 > CSS

父窗口采用js控制iframe页面样式

2015-06-01 20:56 681 查看
父窗口demo

<html>
<head></head>
<script language="javascript">
    function show(){
        //如果当前页与被iframe的页面属于不同域,则调用失效
        window.frames['myframe'].document.getElementsByClassName("titleLink").item(0).href = "javascript:;";
    }
</script>
<body>
<iframe name="myframe" onload="show()" width="100%" src="frame.html">
</body>
</html>


frame.html

<html>
<head></head>
<body>
<iframe name="myframe" onload="show()" width="100%" src="frame.html">
    <a href="http://google.com" class="titlelink">google</a>
    <a href="http://google.com" class="titlelink">google</a>
    <a href="http://google.com" class="titlelink">google</a>
    <a href="http://google.com" class="titlelink">google</a>
    <a href="http://google.com" class="titlelink">google</a>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: