SoFunction
Updated on 2025-03-01

JavaScript implements the copy of the current URL by clicking the button

Click the button to copy the current URL:

There are such functions on a large number of websites. When clicking a button, you can copy the address of the current page, which can facilitate website users to store links and also facilitate website promotion. Here is a description of how to implement this function in combination with examples:

<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="https:///" />
<title>I</title>
</head>
<body>
<input type="button" name="button" value="Copy the title and URL of this page and recommend it to your friends"><br><br>
<script type="text/javascript">
function softwhy() {
 var clipBoardContent = "";
 clipBoardContent += ;
 clipBoardContent += "\n";
 clipBoardContent += ;
 ("Text", clipBoardContent);
 alert("I remind you: Copy successfully!");
}
</script>
</body>
</html> 

The above code can be used to copy the current link by clicking the button, but unfortunately, only IE browser supports this function. The above code is also very simple. If you don’t understand, please feel free to ask. Thank you. !