Skip to content
Advertisement

Tag: url

remove last directory in URL

I am trying to remove the last directory part of an URL. My URL looks like this: https://my_ip_address:port/site.php?path=/path/to/my/folder. When clicking on a button, I want to change this to https://my_ip_address:port/site.php?path=/path/to/my. (Remove the last part). I already tried window.location.replace(//[A-Za-z0-9%]+$/, “”), which results in https://my_ip_address:port/undefined. What Regex should I use to do this? Answer Explanation: Explode by “/”, remove the last element

Get the first part of a url path

If I have a url like: http://localhost:53830/Organisations/1216/View I want to alert the first part of the url path in lowercase format e.g. ‘organisations’ So far I have: but it’s not working as intended. Can anyone help? Thanks Answer

If domain specified not equal to then current URL apply this jQuery as well as pages with same domain

The code below only shows <span> on http://example.com/ but wont show <span> on http://example.com/files/target.html so how can I get it to work on all pages with the specified domain? Please help. Answer What you wrote doesn’t work because window.location returns a Location object, which is a host object. The variable myurl is a string. When comparing a string and an

RegEx to match stuff between parentheses

I’m having a tough time getting this to work. I have a string like: And I need regex or a method of getting each match between the parentheses and return an array of matches like: The regex I’m using is /((.+))/ which does seem to match the right thing if there is only one set of parenthesis. How can I

Difference between document.URL and location.href

I know that document.URL can not be set, while location.href can. But the Document indicates: URL is a replacement for the DOM Level 0 location.href property. So when would we use document.URL? Answer You can get the document.URL, but you can not set it. You can both get and set the location.href. In some webbrowsers, you are able to set

Advertisement