简体   繁体   English

基础href不能用于IE - 替代?

[英]Base href not working on IE - alternative?

So after doing a lot of research I found base href, and I decided I should use it to build my website. 所以经过大量的研究后我找到了基础href,我决定用它来构建我的网站。 After finishing I noticed that it was working on every browser(latest version): Chrome/Firefox/Opera except IE 9. 完成后我注意到它在每个浏览器上工作(最新版本):除了IE 9之外的Chrome / Firefox / Opera。

My site is built like that, on localhost: 我的网站是在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添加在根目录下找到的元素,而不是在当前页面的同一文件夹中:

<?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? 现在我将这个上传到网上,我想基础href将从My_Site更改为http://mysite.com/ ,我想知道这样做之后是否一切都会正常工作? What do I have to do to make it work on IE too? 我还需要做些什么来使它在IE上运行?

You have to use closer tag for base in IE, other browsers require only self-close. 你必须在IE中使用更接近标记的基础,其他浏览器只需要自我关闭。 So it should be: 所以它应该是:

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

(Assuming that href value is correct) (假设href值正确)

You have to use the full path. 你必须使用完整的路径。

Example: 例:

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

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM