getParameter
1 2 3 4 5
| function getParameter(n) { var m = window.location.hash.match(new RegExp('(?:#|&)' + n + '=([^&]*)(&|$)')), result = !m ? '' : decodeURIComponent(m[1]) return result ||getParameterByName(n) }
|
1 2 3 4 5 6 7 8 9
| function getParameterByName(name, url) { if (!url) url = window.location.href name = name.replace(/[\[\]]/g, "\\$&") var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url) if (!results) return null if (!results[2]) return '' return decodeURIComponent(results[2].replace(/\+/g, " ")) }
|
getCookie
1 2 3 4 5 6 7 8
| function getCookie(name){ var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)") if(arr=document.cookie.match(reg)) return unescape(arr[2]) else return null }
|