-3
如何測試URL路徑(最後一個文件夾)如何測試URL路徑(最後一個文件夾)+字符
URL路徑的數目:
http://www.example.com/#/aaaaaaaaa
字符數:AAAAAAAAA
9
Html代碼:
<html>
<body>
<script>
var zz = "http://www.example.com/#/aaaaaaaaa";
if (!$.trim(zz)){
alert("no");
}
else{
alert("ok");
}
</script>
</body>
</html>
我想是這樣的:
http://www.example.com/#/aaaaaaaaa :(9 chars) alert("ok")
http://www.example.com/#/ : alert("no");
http://www.example.com : alert("no");
http://www.example.com/#/aa : alert("no")
http://www.example.com/#/aaaaaaaaaaaaaa : alert("no")
SO是不是要求工作要做的地方你嘗試過什麼? –
使用正則表達式,或只是String.split(如果足夠了),檢索URL的最後部分,然後獲取該字符串的長度 – glennsl