本帖最后由 chate 于 2012-03-13 21:19:25 编辑

解决方案 »

  1.   

    iframe会阻塞页面加载
    把<iframe src="http://m.weather.com.cn/m/pn1/weather.htm " width="235" height="16" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe> 
    的src去掉
    在window.onload = function() {
        var c = document.getElementById('controller').getElementsByTagName('td');
        var ar = ['http://www.baidu.com/s', 'http:m.baidu.com/m'];
        for(var i = 0; i < c.length; i ++) {
            c[i].onclick = function() {
                c[0].style.backgroundColor = '#FFF';
                c[1].style.backgroundColor = '#FFF';
                c[this.cellIndex].style.backgroundColor = '#0FF';
                document.getElementById('searcher').action = ar[this.cellIndex];
            }
        }
    }
    中设置iframe的src
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script type="text/javascript">
    //这样试试
    function changeSearcher(obj) {
    var c = document.getElementById('controller').getElementsByTagName('td');
    var ar = ['http://www.baidu.com/s', 'http://mp3.baidu.com/m'];
    for(var i = 0; i < c.length; i ++) c[i].style.backgroundColor = '#FFF';
    c[obj.cellIndex].style.backgroundColor = '#0FF';
    document.getElementById('searcher').action = ar[obj.cellIndex];
    }
    </script>
    </head><body>
    <table>
      <tr align="center" id="controller">
        <td style="background-color:#0FF" onclick="changeSearcher(this);"><a href="javascript:void(0);">网页</a></td>
        <td onclick="changeSearcher(this);"><a href="javascript:void(0);">音乐</a></td>
      </tr>
      <tr>
        <td colspan="2">
        <form action="http://www.baidu.com/s" target="_blank" id="searcher">
          <input name="word" type="text" value="" />
          <input type="submit" value="百度一下" />
        </form></td>
      </tr>
    </table>
    天气预报:
    <iframe src="http://m.weather.com.cn/m/pn1/weather.htm " width="235" height="16" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe>
    </body>
    </html>
      

  3.   

    我是这样加的:document.getElementById('ifr').src = 'http://m.weather.com.cn/m/pn1/weather.htm';
    解决了一部分问题,但是遇到weather.htm打开速度极慢时,整个网页的链接都无法点击。
      

  4.   

    没改对吧,这样的iframe不会阻塞的。
      

  5.   

    刷新了无数次测试的,也许是我的电脑卡住了?如果你测试不会阻塞那就是这样写吧。只是我的页面里还有统计代码什么的,全部加到window.onload里面比较麻烦,楼上T5500已经圆满回答了,先加分再结贴吧:)
    谢谢二位!