尝试制作一个可以重定向到另一个URL的搜索按钮,并在剪贴板上复制重定向的URL



这是我的html代码:

  <input id="text" type="text" name="text">
    <input type="button" name="page1" onclick="javascript:window.open('http://example.com/' + this.name + '/' + document.getElementById('text').value)">

如果将任何文本放在字段中,然后单击按钮,它将重定向到http://example.com/page1/anytext我正在尝试制作此按钮,以便将其重定向到URL并将其复制到剪贴板。因此,如果任何访问者将anytext放在现场上,它将复制URL http://example.com/page1/anytext并将其重定向到URL。

如下:

function myCopyFunction() {
  var copyText = document.getElementById("page1");
  copyText.select();
  document.execCommand("Copy");
  alert("Copied the text: " + copyText.value);
}

最新更新