Javascript 选择要复制和放置的文件后,此函数不起作用
我无法找出下面函数的真正问题。 它第一次复制,但第二次不起作用。仅保留复制的最后一项 剧本Javascript 选择要复制和放置的文件后,此函数不起作用,javascript,jquery,Javascript,Jquery,我无法找出下面函数的真正问题。 它第一次复制,但第二次不起作用。仅保留复制的最后一项 剧本 function CopiarValorParaClipboard(id) { if (document.selection) { var range = document.body.createTextRange(); range.moveToElementText(document.getElementById(id)); range.select().createTextRa
function CopiarValorParaClipboard(id) {
if (document.selection) {
var range = document.body.createTextRange();
range.moveToElementText(document.getElementById(id));
range.select().createTextRange();
document.execCommand("copy");
} else if (window.getSelection) {
var range = document.createRange();
range.selectNode(document.getElementById(id));
window.getSelection().addRange(range);
document.execCommand("copy");
}
ExibirAlertaInferior('Link copiado!');
}
Html:
@foreach(模型中的变量项)
{
@DisplayFor(a=>item.Nome)
@item.LinkArquivo
@DisplayFor(a=>item.DataValidade)
}
Hey为什么用window.getSelection代替window.getSelection()?Hey为什么用window.getSelection代替window.getSelection()?
@foreach (var item in Model)
{
<tr>
<td style="width: 130px">
@Html.DisplayFor(a => item.Nome)
</td>
<td style="width: 100px">
<p id="Link@(item.ArquivoId)" style="width: 700px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; padding: 0;">@item.LinkArquivo</p>
</td>
<td style="width: 50px">
@Html.DisplayFor(a => item.DataValidade)
</td>
<td class="icones-arquivoslista" style="width: 10%;">
<a class="icone-lista" href="javascript:void(0);" onclick="AbrirCampos('Arquivos', '@item.ArquivoId', '#divCampos', '#divLista')"><i class="fas fa-search"></i></a>
<a class="icone-lista" style="padding-left: 20px" href="javascript:void(0);" onclick="CopiarValorParaClipboard('Link@(item.ArquivoId)')"><i class="fas fa-link"></i></a>
</td>
</tr>
}