Jesus Jesus - 3 months ago 10
Javascript Question

Select image depending of language of my site

Into my view I call static image like this:

<img src="/SiteAssets/new_JoinImage.png" class="img-responsive img-center">


but I want to select another one when my sitepage have change of "en"(English) format

So my language function are

var lang = "Espanol";
if ((window.location.href.indexOf("lang=en") > 0)) {
lang = "English";

}


How can I achieve it? Regards

Answer

You can use the following:

HTML

<img src="/SiteAssets/new_JoinImage.png" class="img-responsive img-center" id="imageOne">

Javascript

    var lang = "Espanol";
    if ((window.location.href.indexOf("lang=en") > 0)) {
        lang = "English";
        document.getElementById("imageOne").src = "/SiteAssets/AnotherImage.png";
    } 
Comments