Если URL-адрес обработчика сообщений равен https://localhost:44360/Contact?handler=Test
, сценарий удара будет фокусировать соответствующую кнопку:
@section scripts{
<script type="text/javascript">
$(document).ready(function () {
$(function () {
var id = 'a[href!="' + getUrlParameter('handler') + '"]';
//$('a[href!="Test"]').focus();
$(id).focus();
});
});
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};
</script>
}