這裏是我的HTML代碼:試圖讓一個搜索按鈕,可以重定向到另一個網址,並複製剪貼板上的重定向URL
<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
,它將複製網址http://example.com/page1/anytext
並重定向到該網址。
的可能的複製[?如何複製JavaScript中的剪貼板(https://stackoverflow.com/questions/400212/how-do-i-copy-to -the-clipboard-in-javascript) – Ali