I have a url like this: http://localhost/something/de/

The last one is the language code de for German. I want to fetch it using javascript. The link may also become like this: http://localhost/something/de/node/artist/117/author/98, in that case how do I fetch the language part.

Actually I want to set up placeholder using javascript, I got the help for placeholder but I dont get how to fetch the language part from url.


You can do this in jQuery, just get the url and then split as required.

$(document).ready(function() {
    var $url = window.location.pathname;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.