location.replace和base tag:IE中的奇怪行为

时间:2015-03-19 10:10:16

标签: javascript html google-chrome internet-explorer url

我的页面中有这个基本标记:

<base href="http://localhost:8080/application/module/jsp/Vues/">

当我在Chrome中测试 location.replace 时,它的行为符合预期,使用基本网址:

location.replace(test)
=> http://localhost:8080/application/module/jsp/Vues/test

但是IE似乎忽略了基本URL并使用了当前位置:

location.replace(test)
=> http://localhost:8080/application/module/jsp/test

为什么IE忽略基本标签的任何想法?如何使两个浏览器具有相同的行为?

1 个答案:

答案 0 :(得分:0)

今天遇到同样的问题。经过长时间的研究,我放弃了并设置了绝对URL。

location.replace(location.origin + baseUrl + relativeUrl);

class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable

如果您的基本元素中有相对路径。