//判斷位址裡是否有?号,如果沒有就從最後一個/截到最後,如果有?就從最後一個/截至?号處
listTable.url = location.href.lastIndexOf("?") == -1 ? location.href.substring((location.href.lastIndexOf("/")) + 1) : location.href.substring((location.href.lastIndexOf("/")) + 1, location.href.lastIndexOf("?"));
listTable.url += "?is_ajax=1";
console.log(listTable.url );
例子:
位址欄裡的位址為:http://localhost/test/9.html
結果為:
9.html??is_ajax=1
位址欄裡的位址為:http://localhost/test/9.html?a=123