我將我的網址與此查詢字符串:得到使用JavaScript和正則表達式
http://mysite.com/results.aspx?s=bcs&k=「醫院」或「辦公室」或「基金」
我想「K =」後搶的一切,但不包括' K =」本身..
而且此正則表達式是部分working..but它抓住具有k兩次一切..
<script type="text/javascript">
document.write('<p>Showing Results for all' +
window.location.href.match(/[?&]k=([^&#]+)/) || [] + '</p>');
</script>
HTTPS://developer.mozilla .org/en/JavaScript/Reference/Global_Objects/String/match讀取關於返回值的部分。 – 2012-02-26 02:13:17