要求当用户点击下拉列表之外的空白处时,重新刷新页面。
页面大致布局是:外面一个DIV,里面是一个LISTBOX。当单击LISTBOX外,DIV以内的范围时,刷新页面。刷新页面时,会用此代码:
<script>window.location.reload();</script>;

解决方案 »

  1.   

    div.click=func();//刷新
    listbox.click=javascript:void(0);
      

  2.   

    我按以上思路做了一个实例,发现点击LISTBOX倒是会刷新。
    不知应该怎样写?
    注:ASP.NET没有CLICK事件。
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>无标题页</title>
        <script type="text/javascript">
          function test()
          {
              window.location.reload();
          }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div onclick="test()">
           <table onclick="javascript:void(0);">
           <tr>
           <td>
            <asp:ListBox ID="ListBox1" runat="server" Width="190px" ></asp:ListBox>
            </td>
            </tr>
           </table>
        </div>
        <asp:Button ID="Button1" runat="server" Text="Button" />
        </form>
    </body>
    </html>
      

  3.   

    注:ASP.NET中LISTBOX是没有单击事件的。
      

  4.   

    一种解决方案,设置全局变量
    <body><script type="text/javascript">
    var refresh = true;
    function func1(){
    if(refresh)
    window.location.reload();
    }
    function func2(){
    refresh = false;
    }
    </script>
    <div onclick="func1()">
    <div>这事div1</div>
    <div onclick="func2()">这是div2</div>
    </div>
    </body>
      

  5.   

    改一下,最外层div赋值下
    <div onclick="javscript:refresh=true;func1()">
      

  6.   

    方案2 用事件源
    <body><script type="text/javascript">function func1(e){
    var src = e.srcElement||e.target;
    if(src.id!="div2")
    window.location.reload();
    }</script>
    <div id="div1" onclick="func1(event)">
    <div>这事div1</div>
    <div id="div2">这是div2</div>
    </div>
    </body>
      

  7.   

    以上方案可行。
    但我的情况是LISTBOX套在DIV里面的。
    要求点击LISTBOX外的DIV时触发。
    如果能这样做到就好了。
      

  8.   

    你可以在你规定的地区,设定一个div,然后在div上设定一个事件onmousemove(),单词可能不到,你查查
    让他就调用一个事件来实现就可以了
      

  9.   

    使用html的select 加上ruant="server"一样,不要局限在aps.net的控件上
      

  10.   

     加上ruant="server"就是服务端控件了。
    呵呵
      

  11.   


    你可以做ajax无刷新 也行