在css中想使用绝对路径来定位图片.但又不能确定web服务器名,要怎样才能在css中得到web服务器名呢? <script>alert(location.protocol+"//"+location.host)</script> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 css中支持expression表示式,你可以参考一下 <style> body{ background-image:expression("url("+ getLocation()+"/images/my.gif));}</style><script>function getLocation(){ return location.host}</script>你可以参考msdn 可以的,你看看expression就知道了 我的意思是在css文件中也可以用javascript? 不是说了,可以!就是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> 我说的是css文件.是不是在css文件中也可以用javascript 别这样说,我就是在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> 如果有错,也只是你jscript的问题了,expression是IE支持的,你自己在别的代码中调用getLocation看看啊,faint JS 如何获取div的兄弟div extjs中的listeners怎么不起作用 高分求new操作的作用!! 如何点击按钮div显示在页面中间,无论滚动条在什么位置的 使用jquery中的sortable拖拽层排序之后的如何保存到数据库? IE 浏览器为什么不会提示错误 关于setInterval和浏览器选项卡切换的问题 请教如何用js实现鼠标右键事件的功能 怎样判断某个input不存在? js书籍,事件处理器有一些不懂请指点 ,web开发为什么要学这么多杂内容 实在是看不懂了,谁帮我解释解释。 history.go("-1") 关于div显示的问题???
body{
background-image:expression("url("+ getLocation()+"/images/my.gif));
}
</style>
<script>
function getLocation(){
return location.host
}
</script>
你可以参考msdn
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>
.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>