Skip to content
Advertisement

Tag: url

Call Javascript function from URL/address bar

Is it possible to call a javascript function from the URL? I am basically trying to leverage JS methods in a page I don’t have access to the source. Something like: http://www.example.com/mypage.aspx?javascript:printHelloWorld() I know if you put javascript:alert(“Hello World”); into the address bar it will work. I suspect the answer to this is no but, just wondered if there was

jQuery Youtube URL Validation with regex

I know there is plenty of question answered over here https://stackoverflow.com/questions/tagged/youtube+regex, but not able find a question similar to me. Any body has the JavaScript Regular expression for validating the YouTube VIDEO URL’s line below listed. Just want to know where such a URL can be possible — update 1– — update 2– This one worked almost fine, but failed

How to extract base URL from a string in JavaScript?

I’m trying to find a relatively easy and reliable method to extract the base URL from a string variable using JavaScript (or jQuery). For example, given something like: http://www.sitename.com/article/2009/09/14/this-is-an-article/ I’d like to get: http://www.sitename.com/ Is a regular expression the best bet? If so, what statement could I use to assign the base URL extracted from a given string to a

Get the current URL with JavaScript?

All I want is to get the website URL. Not the URL as taken from a link. On the page loading I need to be able to grab the full, current URL of the website and set it as a variable to do with as I please. Answer Use: As noted in the comments, the line below works, but it

Equivalent JavaScript functions for Python’s urllib.parse.quote() and urllib.parse.unquote()

Are there any equivalent JavaScript functions for Python’s urllib.parse.quote() and urllib.parse.unquote()? The closest I’ve come across are encodeURI()/encodeURIComponent() and escape() (and their corresponding un-encoding functions), but they don’t encode/decode the same set of special characters as far as I can tell. Answer OK, I think I’m going to go with a hybrid custom set of functions: Encode: Use encodeURIComponent(), then

Get current URL from IFRAME

Is there a simple way to get the current URL from an iframe? The viewer would going through multiple sites. I’m guessing I would be using something in javascript. Answer For security reasons, you can only get the url for as long as the contents of the iframe, and the referencing javascript, are served from the same domain. As long

How can I get query string values in JavaScript?

This question’s answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions. Is there a plugin-less way of retrieving query string values via jQuery (or without)? If so, how? If not, is there a plugin which can do so? Answer Update: Jan-2022 Using Proxy() is faster than using Object.fromEntries()

Parse and add url from clipboard

I need a javascript bookmark to take the url I have in the clipboard parse out the 2 numbers and create a new url, and add a link to the top of the page, that when clicked adds the url to my bookmark menu. Say I have url’s like these http://www.website.com/frontpageeditor.jhtml?sectionID=2844&poolID=6276 javascript:getPoolPageUrl(9800,22713) Then I need to add the numbers to

Advertisement