검색결과 리스트
글
javascript 현재 접속 주소(document.location.href) params 값과 원하는 데이타만 가져오기
js API/javascript
2012. 5. 4. 17:17
javascript 로 현재 접속 URL 을 알아 낼 수 있는 스크립트 함수가
document.location.href 와 document.URL 이 있다. 이 주소로 현재 주소를 불러온다.
< script> // http://apmsoft.tistory.com/test.php?gid=123&n=000 var this_url = document.location.href; < /script>
#@ gid 값만 가져 오기
< script> function parseUrl( url ) { var a = document.createElement('a'); a.href = url; return a; } // ?gid=123&n=000 var s = parseUrl(lux_gaq[i]).search; if(s.match(/gid/)){ var id = s.match(/gid=([^&]+)/)[1]; // gid=123 alert('gid='+id); } < /script>
@ 실습 하기 /===============================================================
< script> var lux_drf=(document.referrer)?encodeURIComponent(document.referrer):encodeURIComponent(parent.document.referrer); var lux_page=(document.location)?encodeURIComponent(document.location):encodeURIComponent(document.URL); var lux_gaq=lux_gaq||[]; lux_gaq.push(['MjNFNzhNUFE5WDE%3D']); lux_gaq.push([lux_drf]); lux_gaq.push([lux_page]); (function(){ var lux_ga=document.createElement('script');lux_ga.type='text/javascript';lux_ga.async=true; lux_ga.src=('https:'==document.location.protocol?'https://ssl':'http://')+'test.com/ga.js'; var lux_gas=document.getElementsByTagName('script')[0];lux_gas.parentNode.insertBefore(lux_ga,lux_gas); })(); < /script>
// test.com/gajs function parseUrl( url ) { var a = document.createElement('a'); a.href = url; return a; } // 주소 : http://test.com/ga.html?kid=NEY2MExOTzFYNDM%3D var lux_params=''; var lux_ak=Array('gid','kid','mid'); for(var i=0;i
'js API > javascript' 카테고리의 다른 글
javascript 한글 영문 포함 문자 길이 간단히 알아내기 (0) | 2012.05.08 |
---|---|
device (디바이스) 체크 및 종류 알아내기 (0) | 2012.04.10 |