打开数据:text/plain window in chrome 显示空白
Opening data:text/plain window in chrome showing up blank
当前功能正常运行并且已经运行多年,但是在最近 3 周内 Chrome 上的用户突然无法访问纯文本文档,但仍在其他浏览器上运行。
基本上函数是这样运行的:
<a class="modo-link" target="_blank" data-modo="4%20Aether%20Hub%0A4%20Botanical%20Sanctum%0A1%20Blooming%20Marsh%0A3%20Forest%0A1%20Island%0A2%20Mountain%0A3%20Rootbound%20Crag%0A1%20Sheltered%20Thicket%0A2%20Spirebluff%20Canal%0A1%20Swamp%0A4%20Bristling%20Hydra%0A3%20Glorybringer%0A4%20Longtusk%20Cub%0A4%20Rogue%20Refiner%0A4%20Servant%20of%20the%20Conduit%0A2%20The%20Scarab%20God%0A4%20Whirler%20Virtuoso%0A2%20Abrade%0A4%20Attune%20with%20Aether%0A2%20Essence%20Scatter%0A4%20Harnessed%20Lightning%0A1%20Magma%20Spray%0A%0ASideboard%0A2%20Cartouche%20of%20Ambition%0A2%20Chandra's%20Defeat%0A1%20Confiscation%20Coup%0A3%20Negate%0A1%20Supreme%20Will%0A2%20Spell%20Pierce%0A1%20Hour%20of%20Glory%0A1%20Struggle%2FSurvive%0A2%20Vizier%20of%20Many%20Faces"><img src="https://227rsi2stdr53e3wto2skssd7xe-wpengine.netdna-ssl.com/wp-content/plugins/crystal-catalog-helper/assets/img/modologo.png"></a>
$('.modo-link').on('click', function() {
var win = window.open('data:text/plain;charset=utf-8,' + $(this).attr('data-modo'), '_blank');
win.focus();
});
例子在这里:
https://www.channelfireball.com/articles/the-return-of-nationals/
只需找到 "Temur Black" 套牌列表并单击图像示例上方的图标:Deckilst icon
我似乎无法弄清楚是什么导致它在 Chrome 中打开空白 window,而它以前工作正常,会不会是 SSL 问题?
谢谢
它不适用于 chrome,但您可以使用替代解决方案,例如:
var w = window.open("");
w.document.write('Your Text Here');
它适用于所有主流浏览器。
我最终使用 Ahmed 的方法让它工作,但我不得不解码 URI 并将中断替换为 <br>
,我认为它会工作得很好。
var win = window.open();
win.document.write(decodeURIComponent($(this).attr('data-modo')).replace(/(?:\r\n|\r|\n)/g, '<br/>'));
win.focus();
但是,如果有人有其他答案可以使用文本保留它,请告诉我。
Chromium 团队 intentionally deprecated and removed the ability to open data URLs。此更改似乎从 Chrome 61 开始生效。
当前功能正常运行并且已经运行多年,但是在最近 3 周内 Chrome 上的用户突然无法访问纯文本文档,但仍在其他浏览器上运行。
基本上函数是这样运行的:
<a class="modo-link" target="_blank" data-modo="4%20Aether%20Hub%0A4%20Botanical%20Sanctum%0A1%20Blooming%20Marsh%0A3%20Forest%0A1%20Island%0A2%20Mountain%0A3%20Rootbound%20Crag%0A1%20Sheltered%20Thicket%0A2%20Spirebluff%20Canal%0A1%20Swamp%0A4%20Bristling%20Hydra%0A3%20Glorybringer%0A4%20Longtusk%20Cub%0A4%20Rogue%20Refiner%0A4%20Servant%20of%20the%20Conduit%0A2%20The%20Scarab%20God%0A4%20Whirler%20Virtuoso%0A2%20Abrade%0A4%20Attune%20with%20Aether%0A2%20Essence%20Scatter%0A4%20Harnessed%20Lightning%0A1%20Magma%20Spray%0A%0ASideboard%0A2%20Cartouche%20of%20Ambition%0A2%20Chandra's%20Defeat%0A1%20Confiscation%20Coup%0A3%20Negate%0A1%20Supreme%20Will%0A2%20Spell%20Pierce%0A1%20Hour%20of%20Glory%0A1%20Struggle%2FSurvive%0A2%20Vizier%20of%20Many%20Faces"><img src="https://227rsi2stdr53e3wto2skssd7xe-wpengine.netdna-ssl.com/wp-content/plugins/crystal-catalog-helper/assets/img/modologo.png"></a>
$('.modo-link').on('click', function() {
var win = window.open('data:text/plain;charset=utf-8,' + $(this).attr('data-modo'), '_blank');
win.focus();
});
例子在这里: https://www.channelfireball.com/articles/the-return-of-nationals/
只需找到 "Temur Black" 套牌列表并单击图像示例上方的图标:Deckilst icon
我似乎无法弄清楚是什么导致它在 Chrome 中打开空白 window,而它以前工作正常,会不会是 SSL 问题?
谢谢
它不适用于 chrome,但您可以使用替代解决方案,例如:
var w = window.open("");
w.document.write('Your Text Here');
它适用于所有主流浏览器。
我最终使用 Ahmed 的方法让它工作,但我不得不解码 URI 并将中断替换为 <br>
,我认为它会工作得很好。
var win = window.open();
win.document.write(decodeURIComponent($(this).attr('data-modo')).replace(/(?:\r\n|\r|\n)/g, '<br/>'));
win.focus();
但是,如果有人有其他答案可以使用文本保留它,请告诉我。
Chromium 团队 intentionally deprecated and removed the ability to open data URLs。此更改似乎从 Chrome 61 开始生效。