<html>
<head>
<meta name="Content-type" type="equiv" content="text/html; charset=utf-8"/>
<title>테스트 파라미터 받기</title>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<p id="param">aaa</p>
<script>
jQuery(function ($) {
$.fn.getUrlParameter = function (sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};
var type = $.fn.getUrlParameter('type');
$("#param").text("type Value : " + type);
});
</script>
</body>
</html>
# 설명
파라미터 type에 값을 넣어주면 스크립트로 값을 받을수 있음( 예 → http://start0.tistory.com/test.html?type=값1111 )
# 실행 예시
type Value : 값1111
'jQuery' 카테고리의 다른 글
[jQuery] jQuery Responsive - matchMedia (not flexible) (0) | 2018.02.05 |
---|---|
[jQuery] display 여부에 따라 show, hide (0) | 2018.02.01 |
[javascript] http와 https 구분없이(혹은 구분해서) 페이지 로딩 (0) | 2017.12.20 |
[jQuery] 텍스트/문자열 변경 및 검색 - indexOf, match 함수, replace 함수, split 함수, html(),text(),val() 메소드 (0) | 2017.12.19 |
[jQuery] each, hasClass (0) | 2017.12.19 |