用JS如何实现窗口自适应大小?

解决方案 »

  1.   

    <body   onload= "window.resizeTo(document.body.scrollWidth,document.body.scrollHeight) "> 
      

  2.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
      <META NAME="Generator" CONTENT="EditPlus">
      <META NAME="Author" CONTENT="">
      <META NAME="Keywords" CONTENT="">
      <META NAME="Description" CONTENT="">
      <script src="jquery-1.4.2.js"></script><script type="text/javascript">
    $(document).ready( function() {    
      for(var i = 0 ; i < $("a[href]").size(); i ++ ){
          //alert($("a:eq("+i+")").attr("href"));
      sl($("a:eq("+i+")").attr("href"));
      }    
    });function sl(id) {
       $("A[href='"+id+"']").click( function() { 
           if ($("#" + $(this).attr('rel') + " INPUT[type='checkbox']").attr('checked') == false) {
           $("#" + $(this).attr('rel') + " INPUT[type='checkbox']").attr('checked', true);            
       } else {
           $("#" + $(this).attr('rel') + " INPUT[type='checkbox']").attr('checked', false);            
       }    
        });
    }function cancelAll() {
       $("input[type='checkbox']").each(function() {
          $(this).attr("checked", false);
       });
    }var str = "";
    function getValue() {
       $("input[type='checkbox']").each(function(){
         if($(this).attr("checked")==true){
            str += $(this).attr("value"); // checkbox的value值由大类和小类组成,不同大类间使用特殊分隔符。
         }
       });
    }
    </script>
     </HEAD> <BODY>
     <table>
     <tr>
     <td>
    <fieldset id="1112" style="border:0px;">
    <input type='checkbox' name='110' id='checkbox_name_1' />1<br />
    <input type='checkbox' name='110' id='checkbox_name_2' />2<br />
    <input type='checkbox' name='110' id='checkbox_name_3' />3<br />
    <input type='checkbox' name='110' id='checkbox_name_4'/>4<br />
    </fieldset>
    <a rel="1112" href="#12">全选/取消全选</a><br /><fieldset id="1113" style="border:0px;">
    <input type='checkbox' name='111' id='checkbox_name_1' />1<br />
    <input type='checkbox' name='111' id='checkbox_name_2' />2<br />
    <input type='checkbox' name='111' id='checkbox_name_3' />3<br />
    <input type='checkbox' name='111' id='checkbox_name_4'/>4<br />
    </fieldset>
    <a rel="1113" href="#13">全选/取消全选</a><br/><input type="button" name="" value="取消选中" onclick="cancelAll();" />
     </td>
     </tr>
     </table>
     </BODY>
    </HTML>
      

  3.   

    $(function(){
    document.oncontextmenu=function(){return false;}//屏蔽右键
    document.onmousemove=mouseMove;//记录鼠标位置
    });