Tips & Tutorials – Javascript

Copy Cut Paste With Javascript (Simple Clipboard Examples)

Welcome to a quick tutorial on how to copy, cut, and paste with Javascript. The Stone Age of the Internet is long over, and yes, we can use Javascript to access the user’s clipboard. Use navigator.clipboard.writeText(“TEXT”) to copy a block to text into the clipboard. var txt = document.getElementById(“TEXT-FIELD”).value; navigator.clipboard.writeText(txt); Use navigator.clipboard.readText() to access the …

Copy Cut Paste With Javascript (Simple Clipboard Examples) Read More »

How To Get URL Parts In Javascript – Host, Path, File, Query, ETC…

Welcome to a quick tutorial on how to get the full URL and parts in Javascript. Need to extract certain parts of the URL? Here are some of the common ones: Use window.location.href to get the full URL. For example – http://site.com/foo/bar.html?key=value Use window.location.origin to get the protocol and hostname. For example – http://site.com/ Use …

How To Get URL Parts In Javascript – Host, Path, File, Query, ETC… Read More »