2012-09-12 28 views
0

我想檢查.aspx後綴,如果它不存在(這是一個Umbraco應用程序,所以可能沒有它),如果它不是我想要添加它到我的路徑,我得到從檢查後綴,如果不存在添加它

假設這將是在php中strpos的jquery等價物。

+0

檢查什麼後綴?網址?一個字符串? –

+0

['String#lastIndexOf'](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/lastIndexOf)或正則表達式。 –

+0

來自url的字符串var pathname = window.location.pathname; – LeBlaireau

回答

1

這應該工作

if (!string.match(/\.aspx$/)) { 
    string+='.aspx'; 
} 
相關問題