¡@

Home 

2014/10/16 ¤W¤È 12:09:52

jquery Programming Glossary: url.substring

Twitter Bootstrap add active class to li

http://stackoverflow.com/questions/11533542/twitter-bootstrap-add-active-class-to-li

Stack with no real joy. I had played with this menu handler function var url window.location.pathname var activePage url.substring url.lastIndexOf ' ' 1 '.nav li a' .each function var currentPage this.href.substring this.href.lastIndexOf ' ' 1 if activePage..

Add / Change parameter of URL and redirect to the new URL

http://stackoverflow.com/questions/13063838/add-change-parameter-of-url-and-redirect-to-the-new-url

function setGetParameter paramName paramValue var url window.location.href if url.indexOf paramName 0 var prefix url.substring 0 url.indexOf paramName var suffix url.substring url.indexOf paramName .substring url.indexOf 1 suffix suffix.indexOf 0.. var url window.location.href if url.indexOf paramName 0 var prefix url.substring 0 url.indexOf paramName var suffix url.substring url.indexOf paramName .substring url.indexOf 1 suffix suffix.indexOf 0 suffix.substring suffix.indexOf url prefix paramName..

Getting URL hash location, and using it in jQuery

http://stackoverflow.com/questions/1822598/getting-url-hash-location-and-using-it-in-jquery

to get the hash from an URL string you can use the String.substring method var url http site.com file.htm#foo var hash url.substring url.indexOf '#' '#foo' Advice Be aware that the user can change the hash as he wants injecting anything to your selector..

How to get the anchor from the URL using jQuery?

http://stackoverflow.com/questions/3552944/how-to-get-the-anchor-from-the-url-using-jquery

this question You can use the .indexOf and .substring like this var url www.aaa.com task1 1.3.html#a_1 var hash url.substring url.indexOf # 1 You can give it a try here if it may not have a # in it do an if url.indexOf # 1 check like this var url.. in it do an if url.indexOf # 1 check like this var url www.aaa.com task1 1.3.html#a_1 idx url.indexOf # var hash idx 1 url.substring idx 1 If this is the current page URL you can just use window.location.hash to get it and replace the # if you wish. share..