Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save poudelmadhav/ffcf9b394cc5a1d93beb156711cb6cc4 to your computer and use it in GitHub Desktop.
Save poudelmadhav/ffcf9b394cc5a1d93beb156711cb6cc4 to your computer and use it in GitHub Desktop.
/************************************************************
<div id="myDropdown" class="dropdown-content">
<a href="/ja/index.html" id="JapaneseLanguage">JAPANESE</a>
<a href="/en/index.html" id="EnglishLanguage">ENGLISH</a>
</div>
*************************************************************/
$( document ).ready(function() {
var ja = document.getElementById("JapaneseLanguage");
var en = document.getElementById("EnglishLanguage");
var currentPath;
var currentUrlPath = window.location.pathname;
if ( (window.location.pathname.lastIndexOf('/en/')) == 0 ) {
currentPath = currentUrlPath.split("/en/")[1];
} else if ( (window.location.pathname.lastIndexOf('/ja/')) == 0 ) {
currentPath = currentUrlPath.split("/ja/")[1];
} else {
currentPath = "index.html";
}
ja.href = '/ja/' + currentPath;
en.href = '/en/' + currentPath;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment