1. 用表单提交
2. 直接在 frameset 网页里这样写:
window.onbeforeunload = function()
{
  alert("meizz");
}

解决方案 »

  1.   

    1.xmlhttp
    2.写在frame中的body里也可以
      

  2.   

    用javascript传值给服务器,违背javascript理念。
      

  3.   

    to java_augur(听着音乐):恩,我也知道javascript主要是在客户端处理数据.
    to vivianfdlpw() :XML我还没接触过,现在功能要的急,所以只有等以后有空了再学习:),至于你说的在frame的body中是指frame里面的其他网页的body里吗?to meizz(梅花雪):第一个用表单提交,比如我现在是如下:
    <html>
    <head>
    <script language=javascript>
    function p()
    {
    var x=location.href;
    }
    </script>
    </head>
    <body>
    <form>
    </form>
    </body>
    </html>
    请问我如何把x的值传回给服务器??
      

  4.   

    frame的src指向的网页中的bodyxmlhttp:<script language=javascript>
    function p()
    {
    var x=location.href;
    var url="http://url"+"&x="+x;
    var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    xmlhttp.open("post",url,false);
    xmlhttp.send();
    }
    </script>
      

  5.   

    楼上的方法挺好,不过 var url="http://url"+"&x="+x; 应为 var url="http://url"+"?x="+x; 吧?
    :)
      

  6.   

    完了。。看不懂。。XML得 可以拿到html里面直接用吗?
      

  7.   

    html+javascript传值给服务器,做不到。
    不明白,你传给服务器干什么?
    location.href="http://xxx"网页就自动跳转了。
      

  8.   

    哦...我需要得到用户当前的URL,我在做交换机的WEB管理系统,并不需要直接用"http://www.csdn.net"这个之类的,我需要判断用户访问web server的地址,而这个地址也是用户可以在交换机上随便配的,因此并不固定.....所以需要利用javascript得到URL的地址传回给服务器......
      

  9.   

    JSP..你能不能举个简单的例子呢
      

  10.   

    <?xml version = "1.0"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><!-- Fig. 10.4: welcome.jsp -->
    <!-- JSP that processes a "get" request containing data. --><html xmlns = "http://www.w3.org/1999/xhtml">   <!-- head section of document -->
       <head>
          <title>Processing "get" requests with data</title>
       </head>   <!-- body section of document -->
       <body>
          <% // begin scriptlet         String name = request.getParameter( "firstName" );         if ( name != null ) {      %> <%-- end scriptlet to insert fixed template data --%>            <h1>
                   Hello <%= name %>, <br />
                   Welcome to JavaServer Pages!
                </h1>      <% // continue scriptlet         }  // end if
             else {      %> <%-- end scriptlet to insert fixed template data --%>            <form action = "welcome.jsp" method = "get">
                   <p> Type your first name and press Submit</p>
          
                   <p><input type = "text" name = "firstName" />
                      <input type = "submit" value = "Submit" />
                   </p>
                </form>      <% // continue scriptlet
             
             }  // end else      %> <%-- end scriptlet --%>
       </body></html>  <!-- end XHTML document --><!--
     ***************************************************************
     * (C) Copyright 2002 by Deitel & Associates, Inc. and         *
     * Prentice Hall. All Rights Reserved.                         *
     *                                                             *
     * DISCLAIMER: The authors and publisher of this book have     *
     * used their best efforts in preparing the book. These        *
     * efforts include the development, research, and testing of   *
     * the theories and programs to determine their effectiveness. *
     * The authors and publisher make no warranty of any kind,     *
     * expressed or implied, with regard to these programs or to   *
     * the documentation contained in these books. The authors     *
     * and publisher shall not be liable in any event for          *
     * incidental or consequential damages in connection with, or  *
     * arising out of, the furnishing, performance, or use of      *
     * these programs.                                             *
     ***************************************************************
    -->
    这是一个“hello world”程序。
    不过要用到其他的容器,比如tomcat,weblogic,resin等等。
      

  11.   

    http://www.coreservlets.com/Apache-Tomcat-Tutorial/
      

  12.   

    我有个这种想法,javascript不是可以给form的某个元素赋值吗?(如document.form.aa.value="jfkd"),能不能把得到的URL象这样赋值给form的某个元素(能不能是hidden的?)然后再通过提交表单时传回服务器?不知道这个想法正确否。
      

  13.   

    这么简单的问题,绕了这么大的圈子,用xmlhttp是最实用也是最常规的方法了
    你上网看一下吧,例子多的是
    //提交xml数据
    var xmlDoc = new ActiveXObject("MSXML2.DOMDocument");
    xmlDoc.async=false;
    xmlDoc.load("loadXML.xml");
    //alert(xmlDoc.xml);
    var xmlhttp = new ActiveXObject("MSXML2.XMLHTTP"); 
      var url = 'Hospital.XMLData.cls';
      xmlhttp.open("post", url, false);
      startstop();  //计时开始   
      xmlhttp.send(xmlDoc);
                      alert(xmlhttp.responseText);