且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

保留数据中的换行符:text URI

更新时间:2023-09-29 15:10:16

My recommended solution is to not use Notepad, because it does not recognize non-Windows line formats. If you still want to be able to use Notepad with your output, replace all line feeds (0x0A) with carriage return+line feed pairs (0x0D 0x0A).

chrome.tabs.create({
    url: 'data:text;base64,' + btoa(data.replace(/\n/g, '\r\n')),
    active: false
});