如何用javascript读取地址栏上的值
http://localhost/article/admin/artcata.asp?oper=edit&id=19如何在
<script language=javascript>
</script>
里取到id的值?
以下例子取得本论坛的boardid
<script language=javascript>
function QueryString(fieldName)
{
var urlString = document.location.search.toLowerCase();
if(urlString != null)
{
var typeQu = fieldName.toLowerCase()+\"=\";
var urlEnd = urlString.indexOf(typeQu);
if(urlEnd != -1)
{
var paramsUrl = urlString.substring(urlEnd+typeQu.length);
var isEnd = paramsUrl.indexOf('&');
if(isEnd != -1)
{
return paramsUrl.substring(0, isEnd);
}
else
{
return paramsUrl;
}
}
else
return null;
}
else
return null;
}alert(\"boardID=\" + QueryString(\"boardID\"))
</script>
[此贴子已经被作者于2006-2-8 22:34:04编辑过]