var blob = new Blob(['insertBook.html'],{type : 'text/html'});
let url = URL.createObjectURL(blob);
console.log(url);
打印:blob:null/731e244f-75e1-4c32-9112-fece97597d16
将本地的链接 insertBook.html,转换成了 blob地址
通过blob去拿去原数据,这个拿到的是insertbook.html 里面的数据
function blobUrlToHtml(the_url,callback) {
urlToBlob(the_url,function(response){
var read=new FileReader();
read.readAsText(response);
read.onload = function () {
if (callback) {
callback(read.result)
}
}
});
};
function urlToBlob(the_url, callback) {
let xhr = new XMLHttpRequest();
xhr.open("get", the_url, true);
xhr.responseType = "blob";
xhr.onload = function() {
if (this.status == 200) {
if (callback) {
callback(this.response);
}
}
};
xhr.send();
};
//iOS 设备上
the_url: blob:null/5a89b8c3-796d-421b-b5b0-9ad5d68a70ba
callback:
<div class="attach-box" id="attach-box" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26, 0.3); -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;"><b class="closeAnnex"></b><div class="attach_item insertNotebook"><div class="folderImg"><img src="blob:null/85d41d95-c32d-4bdf-be25-2bd0b1b3cedf"></div><div class="attach_infor"><h2>外2</h2></div></div></div>
目的其实只是想的到 insertbook.html 这一段字符串
貌似获取不到。。。
这个方法对于blob的图片链接应该是可用的。。
网友评论