Base href not working on IE - alternative?

会有一股神秘感。 提交于 2019-12-24 03:18:17

问题


So after doing a lot of research I found base href, and I decided I should use it to build my website. After finishing I noticed that it was working on every browser(latest version): Chrome/Firefox/Opera except IE 9.

My site is built like that, on localhost:

<base href="/My_Site/" />

Then I use php include to add elements found on root directory and not in the same folder with current page:

<?php include "../header.php"?>

Now since I will be uploading this to the web, I suppose base href will be changed from My_Site to http://mysite.com/ and I wanted to know if everything will be working after doing so? What do I have to do to make it work on IE too?


回答1:


You have to use closer tag for base in IE, other browsers require only self-close. So it should be:

<base href="/My_Site/" /><!--[if IE]></base><![endif]-->

(Assuming that href value is correct)




回答2:


You have to use the full path.

Example:

<base href="<?="http://".$_SERVER['HTTP_HOST']."/"?>My_Site/" />



回答3:


In this case, my guess is that there is some character, outside any tags, before the tag. Consider this:

<base href="http://domain.net/qu/en/" />
<a href="sample">Sample Link</a>


来源:https://stackoverflow.com/questions/12818827/base-href-not-working-on-ie-alternative

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!