如何获取前一页的URL地址,而前一页有弹出alert提示框?比如:
点击 a.html 中的一个按纽,弹出一个alert提示框,然后进入b.aspx
想问, b.aspx如何取得它前一页的URL值,也就是 a.html我用
Response.Write(Request.ServerVariables["HTTP_REFERER"]);
得到的是空值.
如果把alert去掉,那是没问题的我主要是用在这种环境:
   用户要购买产品而未登录,我要提示它"您未登录",转到登录界面,成功以后,自动转到要购买的产品的那个页面,请问取得那一页的URL怎么写?急,谢谢!

解决方案 »

  1.   

    Form认证是用URL传递之前要访问的页面地址的,然后当用户正确登录后,读取get传递的URL再进行跳转
      

  2.   

    用URL传QueryString过去。
    比如百度贴吧
    http://passport.baidu.com/?login&tpl=tb&u=http%3A//tieba.baidu.com/f%3Fkz%3D429947689&aid=6其中&u=http%3A//tieba.baidu.com/f%3Fkz%3D429947689&aid=6的部分
      

  3.   

    关键是 alert 以后,取不到上个页面的Url值,这个怎么解决????????????/
      

  4.   

    Request.Url.AbsoluteUri用这个试试
      

  5.   

    还是用QueryString传递容易点
      

  6.   

    Request.Url.AbsoluteUri 取到的是本面的URL地址,我想要的是上一页的URL,
    也就是有弹出alert提示的那个URL地址..........
      

  7.   

    点击 a.html 中的一个按纽,弹出一个alert提示框,然后进入b.aspx 
    想问, b.aspx如何取得它前一页的URL值,也就是 a.html Response.write("<script>alert('OK');window.location.href='b.aspx?url='a.aspx';</script>");
    这样然后在B页面获取你试试
      

  8.   

    test.htm 页面<html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>Untitled Page</title>
        <script type="text/javascript">
        
        function test()
        {
            alert("未登陆!");
            window.location.href="../test2/login.htm?url="+window.location.href;
            
        }
        </script>
    </head>
    <body>
        <input id="Button1" type="button" value="test" onclick="test()" />
    </body>
    </html>
    login.htm 页面<!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>
        <title>Untitled Page</title>
        <script type="text/javascript">
        function ok()
        {
              str=location.href; //获取本页url地址
            arr=str.split("?");
            str1 = arr[1];
            arr1=str1.split("=");
            window.location.href=arr1[1];
        }
     
        </script>
    </head>
    <body >
        <input id="Button1" type="button" value="login"  onclick="ok()"/>
    </body>
    </html>
      

  9.   

    alert('aa');
    window.location.href='...?url=+'window.location.href;
      

  10.   

    我知道你们的意思,都是要传递一个参数,因为我的网站比较复杂,有些是动态的程序,有些是静态html的,那不好传,一改所有的链接页面都要变,特烦.所以我想用类似于Request.ServerVariables["HTTP_REFERER"])的语句,主要是alert把值给弄没了,我再想想办法不用alert吧,谢谢大家.给分喽..........