不是的,是用js脚本动态加载<base>这个页面标签
这样做的目的是可以动态改变应用的基路径
比如:
<base href="http://localhost/webappA/"/>
<base href="http://localhost/webappB/"/><img src="images/a.jpg"/>对应两种不同的基路径,分别获取的是webappA和webappB中的images/a.jpg用脚本动态加载的核心方法,就是createElement('<base>')
但是该方式对FF下无效,所以限制了通用性,我想找出适用于FF的方式

解决方案 »

  1.   

    createElement(' <base>') 
    楼主自己创建对象时出错,在ff下只传递对象名称就可以了,不能带<>这种符号和它的属性<html>
    <head></head>
    <body><a href='xx.htm'>xx</a>
    <script language="JavaScript">
    window.onload=function(){
    var base=document.createElement("base");
    base.href="http://localhost/doc/";
    document.body.insertBefore(base,document.body.firstChild.nextSibling);alert(document.body.innerHTML)
    }
    </script>
    <a href='xx.htm'>xx</a>
    </body></html>
      

  2.   

    上边哪个是笔误 var head=document.getElementsByTagName('head')[0];
    var e=head.getElementsByTagName('base')[0];
    if(e)e.href=p;
    else
    {
    var base=document.createElement('base');
    base.href='http://localhost/app/';
    head.appendChild(base);
    }这是我使用的一个方法,只在IE下有用,FF下无效果document.body.insertBefore()替代appendChild()是IE,FF通用加载节点的方法么?问题在这里?
      

  3.   

    刚才试了下在ff下还真无法改变base的href,不知道是不是安全的问题不过在初始化时这样输出是可以的<html><head>
    <script>
    base1="http://localhost/base1/"
    base2="http://localhost/base2/"
    document.write('<base href="'+base1+'"/>');
    </script>
    </head><body>
    <a href="b.htm">b.htm</a>
    </body></html>
      

  4.   

    <html><head>
    <script>
    base1="http://localhost/base1/"
    base2="http://localhost/base2/"
    document.write('<base href="'+base1+'"/>');
    </script>
    </head><body>
    <a href="b.htm">b.htm</a>
    </body></html>=========================================
    这样写的话就失去意义了。既然都藕荷到页面里,不是和直接指定一个<base>一样了么?先放着吧。看看还有没有办法。
      

  5.   

    我傻了。。那段脚本也能提出来。这样问题解决了function $setBASE(p)
    {
      document.write(' <base href="'+p+'"/>');
    }
    $setBASE('http://localhost/mytry/');
    OK了,十分感谢