IE doesn't support relative paths in the base element when referencing CSS files

走远了吗. 提交于 2019-11-30 15:30:07

I don't know for sure if this is your issue in IE or not, but according to relevant portion of the HTML 4.01 standards document, the URL in the base href must be an absolute URI. Further, in the example, given it looks like this (with a filename on it):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
 <HEAD>
   <TITLE>Our Products</TITLE>
   <BASE href="http://www.aviary.com/products/intro.html">
 </HEAD>

 <BODY>
   <P>Have you seen our <A href="../cages/birds.gif">Bird Cages</A>?
 </BODY>
</HTML>

In Google searches, I found discussion of what version Firefox added support for relative paths in the base href (which is what you are using) so that is clearly not something that has always been there and not something the 4.01 standard appears to describe.

The HTML5 spec seems to describe and allow base URLs to not have a host portion (host relative) so perhaps that is something that has been added to the specs recently which IE has not supported yet or has not fully supported yet for CSS file loading.

I would suggest you try putting your domain in the base HREF.

According to html specs: http://www.w3.org/TR/html401/struct/links.html refer: Path information: the BASE element section - This attribute specifies an absolute URI that acts as the base URI for resolving relative URIs.

Chrome and Firefox supports relative paths in this tag but IE does not. IE is following the specs strictly.

To manipulate and include absolute url in the base tag, just include script tag after <head> tag as given below

<script type="text/javascript">
document.write("<base href='" + window.location.href.substring(0, location.href
        .indexOf("/context") + 9) + "' />");
</script>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!