<script>
alert(location.protocol+"//"+location.host)
</script>

解决方案 »

  1.   

    css中支持expression表示式,你可以参考一下
      

  2.   

    <style> 
    body{
       background-image:expression("url("+ getLocation()+"/images/my.gif));
    }
    </style>
    <script>
    function getLocation(){
       return location.host
    }
    </script>
    你可以参考msdn
      

  3.   

    可以的,你看看expression就知道了
      

  4.   

    我的意思是在css文件中也可以用javascript?
      

  5.   

    不是说了,可以!就是expression,向下面这个,在css里面table没有cellPadding、cellSpacing属性的,只有js和html标签里面可以设置,通过如下方法可以达到同样的目的<style>
    table { cloudchen:expression(cellSpacing=1,cellPadding=4,border=0);background:#000000;}
    td { background:#ffffff;width:40px;height:30px;}
    </style>
    <TABLE>
    <TR><TD></TD><TD></TD></TR>
    </TABLE>
      

  6.   

    我说的是css文件.是不是在css文件中也可以用javascript
      

  7.   

    别这样说,我就是在css文件中这样使用后发现没有效果,才问的
    .setimage
    {
    background-image: expression(getLocation());
    }<script>function getLocation(){
       if(location.pathname.substr(0,1)=="/")
    {
    VPATH=location.pathname.split("/")[1];
    }
    else
    {
    VPATH=location.pathname.split("/")[0];
    }
    return "url(/"+VPATH+"/web/frame/public/images/up.gif);";
    }
    </script>
      

  8.   

    如果有错,也只是你jscript的问题了,expression是IE支持的,你自己在别的代码中调用getLocation看看啊,faint