プロが教えるわが家の防犯対策術!

お世話になります。
location.href="//xxx/yyy/zzz/index.html"
のとき、
htmlName = location.href.substr(location.href.lastIndexOf("/")+1);
で、htmlName ='index.html'
と、なりますが、
htmlName ='zzz' を取得する方法はないものでしょうか。
よろしくお願いいたします。

A 回答 (1件)

<script>


var arr=location.href.split("/");
alert(arr[arr.length -2])
</script>

とかでどうでしょう?
    • good
    • 0
この回答へのお礼

早速レスありがとうございます。
バッチシです。
なるほどというテクニックで感心しました。
ありがとうございました。

お礼日時:2007/08/23 20:25

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!