我想检查网址格式是否为@Url.Content("~/Dashboard/Index?studentId=")
。如果是,我们必须设置@Url.Content("~/Dashboard/Index")
,如果不是window.location.href
。怎么做?
var currentUrl = (@Url.Content("~/Dashboard/Index?studentId=")) ? (@Url.Content("~/Dashboard/Index")) : window.location.href;
if (currentUrl.indexOf('#') > -1) {
currentUrl = currentUrl.replace('#', '');
}
else {
currentUrl += '#';
}
window.location.href = currentUrl;