数据 URI 链接 <a href="data: 在 Microsoft Edge 中不起作用 [英] Data URI link &lt;a href=&quot;data: doesn&#39;t work in Microsoft Edge

查看:58
本文介绍了数据 URI 链接 <a href="data: 在 Microsoft Edge 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个简单的代码在除 Microsoft Edge 之外的任何地方都能完美运行:

<a href="data:text/plain;charset=utf-8,Test">link</a>

的示例也不适用于相同的结果.

这是 Edge 控制台的输出:

当打开一个新的边缘窗口时会发生这个错误,在新标签上它输入 data:text/plain;charset=utf-8,Test 作为默认搜索引擎的搜索查询.

似乎 Microsoft Edge 没有对 data 的定义:

有人知道解决这个问题的方法吗?

<小时>

更新:不幸的是,似乎无法在 IE/Edge 中的链接中使用数据 URI.我创建了有关检测链接中数据 URI 支持的相关问题:使用 Modernizr 检测链接支持中的数据 URI

解决方案

截至 2020 年,基于 Chromium 的新 Microsoft Edge 支持导航到地址栏中的数据 URI,就像其他基于 Chromium 的浏览器一样.IE 和 Microsoft Edge Legacy 都不支持此功能;MSDN 声称这是出于安全原因.

旧版 Microsoft 浏览器的唯一解决方案是使用 支持的方案(例如 file://或 http://)链接到包含内容的某些资源.

有趣的是,最旧的 IE 版本(我说的是 6 岁以上)在 about: URI 方案中支持数据 URI 的前身,尽管这种方式仅支持 HTML.这些 URI 今天不再有效,只是重定向到导航取消".(以前称为操作已取消"),或者,对于新的 Microsoft Edge,被视为无效的 edge://URI.

This simple code works perfectly everywhere except Microsoft Edge:

<a href="data:text/plain;charset=utf-8,Test">link</a>

[JSFiddle]

In Microsoft Edge I'm getting "That's odd...Microsoft can't find this page" error:

Examples from Mozilla documentation also do not working with the same result.

Here's the output from Edge console:

This error occurs when opening a new edge window, on new tabs it inputs data:text/plain;charset=utf-8,Test as search query into the default search engine.

It seems like Microsoft Edge has no definition for data:

Does anyone know a solution to this?


Update: unfortunately, it seems that there's no way to use data URI in links in IE/Edge. I've created related question about detecting data URI support in links: Detect data URI in links support with Modernizr

解决方案

As of 2020, the new Microsoft Edge built on Chromium supports navigating to data URIs in the address bar like the other Chromium-based browsers. Neither IE nor Microsoft Edge Legacy support this feature; MSDN claims that this is for security reasons.

The only solution for older Microsoft browsers is to link, using a scheme that is supported such as file:// or http://, to some resource that contains the content.

Interestingly enough, the oldest versions of IE (I'm talking older than 6) supported a precursor to data URIs in the about: URI scheme, though only HTML was supported this way. Those URIs no longer work today and simply redirect to "Navigation canceled" (previously "Action canceled") or, in the case of the new Microsoft Edge, are treated as invalid edge:// URIs.

这篇关于数据 URI 链接 <a href="data: 在 Microsoft Edge 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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