備忘錄_20160105(定位)
修改
回首頁
程式 2019-10-10 03:13:23 1570648403 100
用 JavaScript 撰寫二進位檔案並存檔
用 JavaScript 撰寫二進位檔案並存檔
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title></title>
<style>
*
{
margin: 0;
padding: 0;
}
.classTemplate
{
display: block; /* none, block, inline, inline-block */
position: static; /* static, absolute, fixed, relative */
float: none; /* none, left, right */
z-index: 0; /* -int,0,+int */
visibility: visible; /* visible, hidden */
}
</style>
</head>
<body>
<div class="classTemplate">第一行!<br>第二行!</div>
<a id="ida">i am ida</a>
<script>
function gebi(strId)
{
return document.getElementById(strId);
}
const buf = new ArrayBuffer(5);
var view=new Uint8Array(buf);
view[0]=72; // H
view[1]=105; // i
view[2]=9; // [tab]
view[3]=74; // J
view[4]=83; // S
view[5]=33; // !
const blob=new Blob([buf]);
url = window.URL.createObjectURL(blob);
var a=gebi("ida");
a.href = url;
a.download = "thefileName";
a.click();
//window.URL.revokeObjectURL(url);
</script>
</body>
</html>