这是我的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);
}