Click the button to copy the current URL:
A large number of websites have this function. When you click a button, you can copy the address of the current page. This can facilitate website users to store links and facilitate website promotion. Let’s introduce it with examples below. How to implement this feature:
<!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.jb51.net/" /> <title>脚本之家</title> </head> <body> <input type="button" name="button" value="复制本页标题和网址,推荐给您的好友"><br><br> <script type="text/javascript"> function softwhy() { var clipBoardContent = ""; clipBoardContent += document.title; clipBoardContent += "\n"; clipBoardContent += this.location.href; window.clipboardData.setData("Text", clipBoardContent); alert("脚本之家提示:复制成功!"); } </script> </body> </html>
The above code can copy the current link when clicking the button, but unfortunately only IE browser supports this function. The above code is also very simple. If you have any questions that you don’t understand, please feel free to ask. Thank you. !