当前功能正在运行并且已经使用多年,但是在过去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在以前工作正常时打开一个空白窗口,它可能是SSL的东西吗?
由于
答案 0 :(得分:0)
它不适用于Chrome,但您可以使用其他解决方案,如:
var w = window.open("");
w.document.write('Your Text Here');
它适用于所有主流浏览器。
答案 1 :(得分:0)
我最终使用Ahmed的方法让它工作但我必须解码URI并用<br>
替换断点,我认为它会正常工作。
var win = window.open();
win.document.write(decodeURIComponent($(this).attr('data-modo')).replace(/(?:\r\n|\r|\n)/g, '<br/>'));
win.focus();
但是,如果有人有另一个答案来保持使用文字,请告诉我。
答案 2 :(得分:0)
Chromium团队intentionally deprecated and removed the ability to open data URLs。从Chrome 61开始,此更改似乎处于有效状态。