Skip to content

Instantly share code, notes, and snippets.

@tugberkugurlu
Created January 6, 2014 16:05
Show Gist options
  • Save tugberkugurlu/8285005 to your computer and use it in GitHub Desktop.
Save tugberkugurlu/8285005 to your computer and use it in GitHub Desktop.
JavaScript version selector I used before. Saving for future :)
<script>
(function () {
$('select[name="ProductVersion"]').change(function (e) {
var $this = $(this),
desiredVersion = $this.val(),
currentPath = document.location.pathname + document.location.search,
currentPathWithoutVersion = currentPath.substring(currentPath.indexOf('/', 1) === -1 ? currentPath.length : currentPath.indexOf('/', 1), currentPath.length),
targetLocation = '/' + desiredVersion + currentPathWithoutVersion;
document.location = targetLocation;
});
}());
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment