我可以使用协议相关的< base>标签? [英] Can I use a protocol-relative <base> tag?

查看:146
本文介绍了我可以使用协议相关的< base>标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与协议相关的网址可方便地包含资源(图片,CSS,JS )使用与原始请求相同的模式(HTTP或HTTPS),同时只保留缓存页面的单个副本。然后,用户代理决定是否使用HTTP或HTTPS(基于HTML页面的URI)。



我们使用 < base href =../> 标记和HTML中资源的相对URL。 示例:

 < html> 
< head>
< base href =http://example.com/>
< script src =js / foo.jstype =text / javascript/>
< / head>

有没有什么办法可以把这个结合起来? < base /> 标记内的协议相关网址?

 < base href =// example.com/> 

我的实验尤其如此。有时候Internet Explorer会有时候工作,有时甚至不工作(有时甚至连菜单链接都不起作用,有时CSS图像没有被加载)。

有什么可以让我做到的工作或任何建议,如果这是一个好主意?我无法在 caniuse.com 等网站上找到相关信息。 解决方案

我们只是试图通过一个网站进行搜索,而Google的抓取工具并不知道如何使用协议相对路径作为基础,并且我们最终以索引许多损坏的网址为标题。



我不确定在这里使用协议相对路径是否是基本路径的可接受值。浏览器似乎很了解协议的相关基础,但可能是因为他们接受的内容比较宽松。


Protocol-relative URLs make it convenient to include resources (images, CSS, JS) using the same schema (HTTP or HTTPS) as the original request, while keeping only a single copy of the cached page. The user agent then decides, whether or not to use HTTP or HTTPS (based on the URI of the HTML page).

We are using the <base href=".." /> tag and relative URLs to resources in the HTML.

An example:

<html>
<head>
  <base href="http://example.com" />
  <script src="js/foo.js" type="text/javascript" />
</head>

Is there any way that I can combine this? Protocol-relative URLs within a <base/> tag?

<base href="//example.com" />

My experiments esp. with Internet Explorer worked sometimes and sometimes not (sometimes even menu links didn't work, sometimes CSS images were not loaded).

Is there anything so that I can make it work or any recommendation if it is a good idea? I was not able to find information on sites like caniuse.com.

解决方案

We just attempted this with a site and Google's crawler did not understand how to use a protocol relative path as the base and we ended up with it indexing many broken urls.

I'm not sure if using a protocol relative path here is an acceptable value for the base path. Browser's seem to understand the protocol relative base just fine, but it could be that they are just more lenient in what they will accept.

这篇关于我可以使用协议相关的&lt; base&gt;标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆