Click here to Skip to main content
15,798,592 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
JavaScript
$(document).ready(function(){
    var url = "http://relaunch.domain.local/projekte";
    var arguments = url.split('http')[1].split('//');
    arguments.shift();
    alert(arguments)
});


What I have tried:

This is my sample code

How to get this (relaunch) from URL.
Posted
Updated 2-Aug-21 23:24pm
v2
Comments
Richard MacCutchan 3-Aug-21 3:27am    
var arguments = url.split('//')[1].split('.')[0];

1 solution

For parsing a URL, use the URL API:
URL - Web APIs | MDN[^]
JavaScript
const url = new URL("https://test.host.local/path/to/page?foo=bar");
const name = url.hostname.split('.')[0];
alert(name); // "test"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900