<html>
<script>
function test()
{
for(i=0;i<window.frames.length;i++)
{
window.frames[i].location="about:blank";
}
window.frames[0].location="a.htm";

}
</script>
<body onload="test()">
<iframe src="a.htm" width="100" heigth="100">
<iframe src="b.htm" width="100" heigth="100">
</body>
</html>你看这样能不能满足你的要求

解决方案 »

  1.   

    2楼回答的很不错噢
    不过要是你学过SEO就不会放那么多广告的
    GOOGLE的广告一个页面不超过2个
    做过SEO的人都知道
    优化网站的第一部就是靠GOOGLE
    你放那么多
    那么网页的单价点击接很少了的
      

  2.   

    是啊,,不过主页面不是我能控制的哦,,我只能控制iframe里面的网面,
    可不可以在iframe里面调用的网页里面加入互斥啊?
      

  3.   

    主页面我什么也控制不了,也不能插入JS,只能插入iframe,所以我放了iframe,当时没注意,只想着可以放很多广告,结果每个页面里面放了四个iframe,调用同一个广告页面,
    如果我修改其中一个iframe里面的内容为空,哪全部为空了,也就没广告了,要是不清除,哪就有4个广告,好晕,,把我想他能不能一个互斥的,第一个iframe运行以后,哪后面的就去判断该子页面是否己在该页面执行过,如果执行过,哪就不执行了,,
    (我只能控制iframe所调用的页面哦!)
      

  4.   


    <html>
        <script>
            function test()
            {
                for(i=0;i<parent.frames.length;i++)
                {
                    parent.frames[i].location="about:blank";
                }
                parent.frames[0].location="a.htm";
                
            }
        </script>
        <body onload="test()">
            <iframe src="a.htm" width="100" heigth="100">
            <iframe src="b.htm" width="100" heigth="100">
        </body>
    </html>
    把代码写在任一个框架页内,把window改为parent就行了。
      

  5.   

    终于遇到高人了:把握机会,HOHO
    还是不大明白哦,
        <body onload="test()">
            <iframe src="a.htm" width="100" heigth="100">
            <iframe src="b.htm" width="100" heigth="100">这里也是调用a.htm
        </body>
    如何window哈,要他们互斥,是不是有一个他们共享的标志哈?
    第一个iframe运行后,就改变该标志,后面检测该标志的值,判断a.htm是否己经运行过
      

  6.   

    互斥是指什么?是指4个当中只能出现其中一个?具体结构是怎样的?
    你的iframe结构如何?
      

  7.   

    结构吧,就像是:
    <html>
       <body>
            <iframe src="a.htm" width="100" heigth="100">
            <iframe src="a.htm" width="100" heigth="100">
            <iframe src="a.htm" width="100" heigth="100">
            <iframe src="a.htm" width="100" heigth="100">
        </body>
    </html>
    哪果a.htm里面是google广告,哪在这个页面里面,他们出现四个广告哦,哪相对于GOOGLE的政策,问题就严重了
    我希望他在第一个iframe调用成功后,哪后面就不调用了,
    我的权限,也只能修改a.htm里面的代码,这里面如何修改,才能让他只运行一次呢?
    我曾经有个思路,是在里面初始一个变量flag,先判断他是否等于1,如果是1,哪就停止加载页面,如果变量非1,哪在他一调用iframe后,里面的变量开始赋值flag=1,哪后面的iframe,也会照这个过程去判断,但是我没有想到iframe里面的变量和父窗口里面的变量是不通用了,所以我在找一个他们能共同访问的焦点,然后通过设置这个焦点去判断,当初一时的失误,带来的麻烦,好晕,,
    现求各位高手不吝赐教!
      

  8.   

    呵呵,你只能修改a.htm里面的代码,那么你只能使用parent.frames
    还有你的iframe有没有name?还有是否只有广告得iframe,还是还有其他的,这些都会影响倒做法的
      

  9.   

    <script>
            function test()
            {
                for(i=1;i<parent.frames.length;i++)
                {
                    parent.frames[i].location="about:blank";
                }
            }
    </script>那这样就行了
      

  10.   

    你这个方法也不一定可以行得通,假设还有其他的frames,不是这些广告的话,那就都把那些也改取消掉了
      

  11.   


    如果他能修改top window 页面的代码,那就加入id或name来识别,
    如果不能修改top window 页面的代码,就人工数下是哪几个框架,根据情况作修改就行了,这个只是基本实现。
      

  12.   

    如果互斥的话,建议用Select Case语句
      

  13.   

    YH_Random的说法值得研究,我测试一下,HOHO,我可以只用一个框架
    15楼的朋友,select case在此如何应用啊?
      

  14.   

    这些都不太现实!!假如哪天top window 页面改变了,右要去数和改!这样的效率还可能?
      

  15.   

    呵呵
    <html>
       <body>
            <iframe src="a.htm" width="100" heigth="100">
            <iframe src="a.htm" width="100" heigth="100">
            <iframe src="a.htm" width="100" heigth="100">
            <iframe src="a.htm" width="100" heigth="100">
        </body>
    </html>全部这样的还命名有什么规律???这个就是要靠他说的那个来数多少个来控制
      

  16.   


    if (parent.frames[i].src="a.htm")
    {
      parent.frames[i].location="about:blank";
    }   
      

  17.   

    1 YH_Random 的方法:如果你对top有权限设置变量的话,利用这个变量做互斥
    2 kongxiangli 的方法:遍历每个iframe在你的a.htm中处理onload事件
    window.onload()
    {
    window.top.变量 = true/false;
    或者:
    for(...)
    {
     if(iframe.src == "a.htm")
     {
       window.location = "about blank";
     }
    }
    }
      

  18.   

    if (parent.frames[i].src="a.htm") 

      parent.frames[i].location="about:blank"; 
    }
    else
    {
               //广告脚本???
    }
      

  19.   

    // 如果有iframe的src等于广告地址
    if (parent.frames[i].src == "a.htm")  
    {
      // 那么当前的广告地址应该为空了
      window.location = "about:blank";
    } 不用else了,因为已经跳转了。
    不过这有问题:因为你自己这个页面也属于iframe并且它的src是a.htm
    所以你还要加上判断不是当前页面。