EzDevInfo.com

url interview questions

Top url frequently asked interview questions

Change the URL in the browser without loading the new page using JavaScript

How would I have a JavaScript action that may have some effects on the current page but would also change the URL in the browser so if the user hits reload or bookmark the new URL is used?

It would also be nice if the back button would reload the original URL.

I am trying to record JavaScript state in the URL.


Source: (StackOverflow)

How can I get the Google cache age of any URL or web page?

In my project I need the Google cache age to be added as important information. I tried to search sources for the Google cache age, that is, the number of days since Google last re-indexed the page listed.

Where can I get the Google cache age?


Source: (StackOverflow)

Advertisements

URL encoding in Android

How do you encode a URL in Android?

I thought it was like this:

final String encodedURL = URLEncoder.encode(urlAsString, "UTF-8");
URL url = new URL(encodedURL);

If I do the above, the http:// in urlAsString is replaced by http%3A%2F%2F in encodedURL and then I get a java.net.MalformedURLException when I use the URL.


Source: (StackOverflow)

What is the maximum length of a URL in different browsers?

What is the maximum length of a URL in different browsers? Does it differ between browsers?

Does the HTTP protocol dictate it?


Source: (StackOverflow)

How do I get the current absolute URL in Ruby on Rails?

How can I get the current absolute URL in my Ruby on Rails view?

The request.request_uri only returns the relative URL.


Source: (StackOverflow)

Path.Combine for URLs?

Path.Combine is handy, but is there a similar function in the .NET framework for URLs?

I'm looking for syntax like this:

Url.Combine("http://MyUrl.com/", "/Images/Image.jpg")

which would return:

"http://MyUrl.com/Images/Image.jpg"


Source: (StackOverflow)

How can I open a URL in Android's web browser from my application?

How to open an URL from code in the built-in web browser rather than within my application?

I tried this:

try {
    Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(download_link));
    startActivity(myIntent);
} catch (ActivityNotFoundException e) {
    Toast.makeText(this, "No application can handle this request."
        + " Please install a webbrowser",  Toast.LENGTH_LONG).show();
    e.printStackTrace();
}

but I got an Exception:

No activity found to handle Intent{action=android.intent.action.VIEW data =www.google.com

Source: (StackOverflow)

How can I get query string values in JavaScript?

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?


Source: (StackOverflow)

Modify the URL without reloading the page

Is there any way I can modify the URL of the current page without reloading the page?

I would like to access the portion before the # hash if possible.

I only need to change the portion after the domain, so its not like I'm violating cross-domain policies.

 window.location.href = "www.mysite.com/page2.php";  // sadly this reloads

Source: (StackOverflow)

Capturing url parameters in request.GET

I am currently defining regular expressions in order to capture parameters in a url, as described in the tutorial. How do I access parameters from the url as part the HttpRequest object? My HttpRequest.GET currently returns an empty QueryDict object.

I'd like to learn how to do this without a library so I can get to know Django better.


Source: (StackOverflow)

Change the URI (URL) for a remote Git repository

I have a repo (origin) on a USB key that I cloned on my hard drive (local). I moved "origin" to a NAS and successfully tested cloning it from here.

I would like to know if I can change the URI of "origin" in the settings of "local" so it will now pull from the NAS, and not from the USB key.

For now, I can see two solutions:

  • push everything to the usb-orign, and copy it to the NAS again (implies a lot of work due to new commits to nas-origin);

  • add a new remote to "local" and delete the old one (I fear I'll break my history).


Source: (StackOverflow)

Get current URL in web browser

How do I get the website URL?

Not the URL as taken from a link. On the loading page, I want to get the full, current URL of the current web page and store its value in a variable.


Source: (StackOverflow)

What is the best regular expression to check if a string is a valid URL?

How can I check if a given string is a valid URL address?

My knowledge of regular expressions is basic and doesn't allow me to choose from the hundreds of regular expressions I've already seen on the web.


Source: (StackOverflow)

How to get the value from the URL parameter?

I have a URL with a parameter as follows,

www.test.com/t.html?a=1&b=3&c=m2-m3-m4-m5

I need to get the whole value of c. I tried to read the URL, but I got only m2. How do I do this using JavaScript?


Source: (StackOverflow)

What's the shebang/hashbang (#!) in Facebook and new Twitter URLs for?

I've just noticed that the long, convoluted Facebook URLs that we're used to now look like this:

http://www.facebook.com/example.profile#!/pages/Another-Page/123456789012345

As far as I can recall, earlier this year it was just a normal URL-fragment-like string (starting with #), without the exclamation mark. But now it's a shebang or hashbang (#!), which I've previously only seen in shell scripts and Perl scripts.

The new Twitter URLs now also feature the #! symbols. A Twitter profile URL, for example, now looks like this:

http://twitter.com/#!/BoltClock

Does #! now play some special role in URLs, like for a certain Ajax framework or something since the new Facebook and Twitter interfaces are now largely Ajaxified? Would using this in my URLs benefit my Web application in any way?


Source: (StackOverflow)