我有以下链接:
<ul id="countrySelect">
<ul>
<li><a href="setlocale.aspx?returnURL=Default.aspx&localesetting=en-US">EN</a></li>
</ul>
<ul>
<li><a href="setlocale.aspx?returnURL=Default.aspx&localesetting=cs-CZ">CZ</a></li>
</ul>
<!-- END COUNTRY SELECT LIST -->
<p></p>
</ul>
我想Default.aspx
从 returnURL 中删除并将其替换为用户所在的当前页面。这是我尝试过的,但不确定它是否正确?
var pathname = window.location.pathname;
var countryArr = [];
var $ul = $('<ul id="countrySelect"/>');
countryArr = $('ul#countrySelect ul li a').map(function() {
return this.value;
}).get();
$.each(countryArr, function() {
$ul.append('<li>' + '<a href="setlocale.aspx?returnURL=' + pathname + '&localesetting=' + this.slice(0) + '">' + this.slice(3) + '</a>');
});