本帖最后由 u013067835 于 2013-12-25 21:33:24 编辑

解决方案 »

  1.   

    <input type='text' id='search'>
    <input type='button' id='bd' value='百度'>
    <input type='button' id='gg' value='谷歌'>
    <script>document.getElementById('bd').onclick =function(e){
    var v = document.getElementById('search').value;
     location.href='http://www.baidu.com/s?wd='+v;
    }
    document.getElementById('gg').onclick =function(e){
    var v = document.getElementById('search').value;
     location.href='http://www.google.com.hk/search?newwindow=1&safe=strict&site=&source=hp&q='+v;
    }
    </script>
      

  2.   

    <input type='text' id='search'>
    <input type='button' id='bd' value='百度'>
    <input type='button' id='gg' value='谷歌'>
    <script>document.getElementById('bd').onclick =function(e){
    var v = document.getElementById('search').value;

    window.open('http://www.baidu.com/s?wd='+v);
     
    }
    document.getElementById('gg').onclick =function(e){
    var v = document.getElementById('search').value;
     //location.href='http://www.google.com.hk/search?newwindow=1&safe=strict&site=&source=hp&q='+v;
     window.open('http://www.google.com.hk/search?newwindow=1&safe=strict&site=&source=hp&q='+v);
    }
    </script>