Get started with urljs CDN
Stable version
Copied!
How to start using urljs CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with urljs CDN - cdnhub.io</title>
<script src="https://cdn.cdnhub.io/urljs/2.7.0/url.min.js"></script>
</head>
<body>
<script>
// Create a new URL object
const urlObj = new URL('https://example.com/path/to/file.html?query=param1&query=param2');
// Parse the URL and access its components
const urlParts = new URLSearchParams(urlObj.search);
const queryParam1 = urlParts.get('query'); // 'param1'
const queryParam2 = urlParts.get('query'); // 'param2'
// Manipulate the URL object
urlObj.searchParams.set('query', 'newParam');
urlObj.hash = '#newHash';
// Display the modified URL
console.log(urlObj.toString()); // 'https://example.com/path/to/file.html?query=newParam#newHash'
</script>
</body>
</html>
Copied!