在Stackoverflow页面上,副本到剪贴板可以正常工作但是当我将脚本添加到可爱文件浏览器中以复制链接时,单击它不起作用,浏览器也会忽略
e.preventDefault()
代码。你能帮帮我说什么错了吗?
所以这是来自script.js并添加了代码:
// Clicking on breadcrumbs
breadcrumbs.on('click', 'a', function(e){
e.preventDefault();
var index = breadcrumbs.find('a').index($(this)),
nextDir = breadcrumbsUrls[index];
breadcrumbsUrls.length = Number(index);
//before it was window.location.hash instead of var cope
var cope = encodeURIComponent(nextDir);
var aux = document.createElement("input");
aux.setAttribute("type", "text");
aux.setAttribute("id", "temp");
aux.setAttribute("style", "position:absolute;opacity:0;");
aux.setAttribute("value", cope);
document.body.appendChild(aux);
aux.select();
document.execCommand("copy");
document.body.removeChild(aux);
});
我做错了什么?