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

来源:互联网 发布:windows mobile 手机 编辑:程序博客网 时间:2024/05/16 10:27

父窗口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>


0 0
原创粉丝点击