<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>js創(chuàng)建 網(wǎng)頁-桌面快捷方式</title>
<style>
#downdiv{
position:fixed;
top:30px;
right:30px;
z-index:9999999;
}
#downdiv input{
display: block;
width: 100%;
}
#down_btn {
font-size:50px;
color:lawngreen;
}
</style>
</head>
<body>
js創(chuàng)建 網(wǎng)頁-桌面快捷方式
<script type="text/javascript">
// javascript:
(function() {
var content=`[{000214A0-0000-0000-C000-000000000046}] \n
Prop3=19,11 \n
[InternetShortcut] \n
IDList= \n
URL=${location.href} \n
IconFile=${location.protocol}//${location.hostname}/favicon.ico \n
IconIndex=1 \n
`;
var downdiv = document.createElement("div");
downdiv.id="downdiv";
downdiv.innerHTML=`
<style>
#downdiv{
position:fixed;
top:30px;
right:30px;
z-index:9999999;
}
#downdiv input{
display: block;
width: 100%;
}
#down_btn {
font-size:50px;
color:lawngreen;
}
</style>
名稱:<input type="text" id="sitetitle" value="__${document.title}__url" />
網(wǎng)址:<input type="text" id="siteurl" value="${location.href}" />
`;
var down_btn = document.createElement("button");
down_btn.innerText = "下載 URL桌面快捷方式";
down_btn.title = "注意查看,下載文件";
down_btn.id = "down_btn";
downdiv.appendChild(down_btn);
document.body.appendChild(downdiv);
var eledowndiv = document.querySelector("#downdiv");
var eleButton = document.querySelector("#down_btn");
var funDownload = function(content, filename) {
var eleLink = document.createElement("a");
eleLink.download = filename;
eleLink.style.display = "none";
var blob = new Blob([content]);
eleLink.href = URL.createObjectURL(blob);
document.body.appendChild(eleLink);
eleLink.click();
document.body.removeChild(eleLink)
};
if ("download" in document.createElement("a")) {
eleButton.addEventListener("click", function() {
var sitename =document.querySelector('#sitetitle').value||document.title;
document.body.removeChild(eledowndiv);
funDownload(content, sitename + ".url")
})
} else {
eleButton.onclick = function() {
alert("瀏覽器不支持")
}
}
})();
</script>
<script type="text/javascript-------------書簽工具 添加書簽,地址欄 copy 如下代碼 --------------">
javascript:(function(){var content=`[{000214A0-0000-0000-C000-000000000046}]\nProp3=19,11\n[InternetShortcut]\nIDList=\nURL=${location.href}\nIconFile=${location.protocol}//${location.hostname}/favicon.ico\nIconIndex=1\n`;var downdiv=document.createElement("div");downdiv.id="downdiv";downdiv.innerHTML=`<style>#downdiv{position:fixed;top:30px;right:30px;z-index:9999999}#downdiv input{display:block;width:100%}#down_btn{font-size:50px;color:lawngreen}</style>名稱:<input type="text"id="sitetitle"value="__${document.title}__url"/>網(wǎng)址:<input type="text"id="siteurl"value="${location.href}"/>`;var down_btn=document.createElement("button");down_btn.innerText="下載 URL桌面快捷方式";down_btn.title="注意查看,下載文件";down_btn.id="down_btn";downdiv.appendChild(down_btn);document.body.appendChild(downdiv);var eledowndiv=document.querySelector("#downdiv");var eleButton=document.querySelector("#down_btn");var funDownload=function(content,filename){var eleLink=document.createElement("a");eleLink.download=filename;eleLink.style.display="none";var blob=new Blob([content]);eleLink.href=URL.createObjectURL(blob);document.body.appendChild(eleLink);eleLink.click();document.body.removeChild(eleLink)};if("download"in document.createElement("a")){eleButton.addEventListener("click",function(){var sitename=document.querySelector('#sitetitle').value||document.title;document.body.removeChild(eledowndiv);funDownload(content,sitename+".url")})}else{eleButton.onclick=function(){alert("瀏覽器不支持")}}})();
</script>
</body>
</html>