How could I change window’s location without reloading and # hack?

Facebook is using the history api in HTML5. From this blog post you can see how this works. Basically they are making calls like the one below to change the url without reloading the page. window.history.pushState(“object or string”, “Title”, “/new-url”); Here is the HTML5 working draft spec about it: http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#the-location-interface Sadly, IE9 does not support … Read more

How can I pre-populate html form input fields from url parameters?

Use a custom query string Javascript function. function querySt(ji) { hu = window.location.search.substring(1); gy = hu.split(“&”); for (i=0;i<gy.length;i++) { ft = gy[i].split(“=”); if (ft[0] == ji) { return ft[1]; } } } var koko = querySt(“koko”); Then assign the retrieved value to the input control; something like: document.getElementById(‘mytxt’).value = koko;

IIS7 URL Redirection from root to sub directory [closed]

Here it is. Add this code to your web.config file: <system.webServer> <rewrite> <rules> <rule name=”Root Hit Redirect” stopProcessing=”true”> <match url=”^$” /> <action type=”Redirect” url=”/menu_1/MainScreen.aspx” /> </rule> </rules> </rewrite> </system.webServer> It will do 301 Permanent Redirect (URL will be changed in browser). If you want to have such “redirect” to be invisible (rewrite, internal redirect), then … Read more

how to validate a URL / website name in EditText in Android?

Short answer Use WEB_URL pattern in Patterns Class Patterns.WEB_URL.matcher(potentialUrl).matches() It will return True if URL is valid and false if URL is invalid. Long answer As of Android API level 8 there is a WEB_URL pattern. Quoting the source, it “match[es] most part of RFC 3987”. If you target a lower API level you could … Read more

REST API DESIGN – Getting a resource through REST with different parameters but same url pattern

In my experience, GET /users/{id} GET /users/email/{email} is the most common approach. I would also expect the methods to return a 404 Not Found if a user doesn’t exist with the provided id or email. I wouldn’t be surprised to see GET /users/id/{id}, either (though in my opinion, it is redundant). Comments on the other … Read more

How to encode URL parameters?

With PHP echo urlencode(“http://www.image.com/?username=unknown&password=unknown”); Result http%3A%2F%2Fwww.image.com%2F%3Fusername%3Dunknown%26password%3Dunknown With Javascript: var myUrl = “http://www.image.com/?username=unknown&password=unknown”; var encodedURL= “http://www.foobar.com/foo?imageurl=” + encodeURIComponent(myUrl); DEMO: http://jsfiddle.net/Lpv53/