body{text-align: center;}
textarea{width: 60%;height:180px;border: 2px solid #ccc;display: block;margin: 10% auto 0;padding: 0.5em;outline: none;box-shadow: 0;transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;}
textarea:focus{border: 2px solid #80bdff;box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);}
.btn {display: inline-block;font-weight: 400;color: #212529;text-align: center;vertical-align: middle;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;background-color: transparent;border: 1px solid transparent;padding: .375rem .75rem;font-size: 1rem;line-height: 1.5;border-radius: .25rem;cursor: pointer;margin: 20px auto;box-sizing: border-box;transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;}
.btn-primary {color: #fff;background-color: #007bff;border-color: #007bff;}
btn-primary:hover {color: #fff;background-color: #0069d9;border-color: #0062cc;}
function attEvt(evtName, fn) {
if (window.attachEvent)
window.attachEvent('on' + evtName, fn);
else
window.addEventListener(evtName, fn, false);
}
// attEvt('load', function () {
// var as = document.getElementsByTagName("A");
// for (var i = 0; i < as.length; i++) {
// var a = as[i];
// a.href = decodeURIComponent(a.href);
// }
// document.getElementById("txt").value = a.href;
// });
http://book.yhqtb.vip/#/chapter/%E6%88%91%E5%9C%A8%E4%B8%9C%E5%8C%97%E5%BD%93%E7%89%B9%E5%B7%A5/%E7%AC%AC2%E7%AB%A0%E7%81%AD%E5%8F%A3
转换↓
复制
window.onload = function(){
var btn = document.getElementById('button');
var copy = document.getElementById('copy');
var decodeURI = document.getElementById("decodeURI");
btn.addEventListener('click',function(){
var inlink = document.getElementById('txt').value.replace(/\s+/g,"");
decodeURI.value = decodeURIComponent(inlink);
});
copy.addEventListener('click',function(){
decodeURI.focus();
decodeURI.select();
document.execCommand("copy", true, null);
// decodeURI.blur();
})
}
提示:你可以先修改部分代码再运行。