thisUrl = window.location.href;

解决方案 »

  1.   

    thisUrl = window.location.href;
      

  2.   

    window.location       是一个对象
    window.location.href  返回的才是当前网页的链接字符串
      

  3.   

    将location对象转化为它的字符串形式thisUrl = window.location; => thisUrl = window.location.toString();
      

  4.   

    thisUrl = window.location.href;
      

  5.   

    ?是对象?为什么alert(window.location);不显示 [object] 而显示路径信息?
    或者说我们经常window.location='http://url';。这样写是不严谨的做法?
      

  6.   

    手册上说:
    location.href是location的默认属性 
    设置location='http://microsoft.com' 和设置
    location.href='http://microsoft.com'. 
    是相同的
      

  7.   

    不,window.location确实是对象,只是他的toString()方法会呈现出window.location.href值alert时对象会默认调用该对象的toString()方法,所以程序字符串而赋值时也会调用toString()方法的,即对其href属性赋值。确实不严谨,但dom约定俗成的东西简化倒也并非大问题,只要明白概念
      

  8.   

    thisUrl = window.location.toString()
    或者
    thisUrl = ""+window.location;
      

  9.   

    thisUrl = window.location; 改成thisUrl = window.location.url;就OK啦^_^