---
title: "IE js中使用window.location时会忽略base href值"
author: "laiahu"
date: "2014-03-04T17:28:18Z"
tags: []
categories: ["Web前端"]
slug: "ie-js-window-location-base-href"
draft: false
lastmod: "2014-03-04T17:41:44Z"
id: 2025536
url: "https://laiahu.iteye.com/blog/2025536"
---

来源: http://blog.csdn.net/kjb000/article/details/7913867

 

IE的js 中使用Window.location时会忽略base href值 

这样写可以解决:

window.location = document.getElementsByTagName("base")\[0].getAttribute("href")+ "loc";

 

 

获得 base也可以用：

alert("base="+$("#base").attr("href"));