IE8对base标签不能很好兼容

原来,我是这么写代码的:javascript

<base href="<%=basePath %>" />java

……浏览器

window.location = "user/search?pageNum="+pageNum+"&everyPageCount="+everyPageCount+"&username="+username;ip

若是你也这么搞,你会发现,你的代码在除了IE的浏览器都比较好使,至于IE……呵呵。get

解决方案: io

不过,鉴于IE在国内具备无与伦比的统治地位,因此,我换了个写法:解决方案

<script type="text/javascript">
//解决IE对base不能很好支持的问题
var base = document.getElementsByTagName("base")[0].getAttribute("href");
window.location = base+"user/search?pageNum="+pageNum+"&everyPageCount="+everyPageCount+"&username="+username;script

……document

</script>location

OK,问题解决。

相关文章
相关标签/搜索