336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
안녕하세요. 이번엔 JAVASCRIPT에서 background 이미지와 이미지 크기 및 반복 안하는 방법에 대해서 간단하게 알려드리겠습니다..
1
2
3
4
5
6
7
8
9
10
11
12
13
14 |
<script>
window.onload = function(){
//반복제거, url
document.getElementById("div").style.backgroundRepeat = "no-repeat";
//이미지 등록
document.getElementById("div").style.backgroundImage = "url('해당파일위치')";
//이미지 사이즈
document.getElementById("div").style.backgroundSize = "200px";
}
</script>
<div id='div'>
</div>
|
cs |
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
안녕하세요. 이번엔 JQUERY에서 URL을 가져오는 방법을 알려드리겠습니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14 |
<!-- jquery를 불러옵니다. jquery.com download 페이지를 참조해주세요 -->
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script>
window.onload = function(){
//전체주소
console.log("url : "+$(location).attr('href'));
//http:, localhost:port번호, index.html ?test=tttt 순으로 나누어져 있습니다.
console.log("url : "+$(location).attr('protocol')+"//"+$(location).attr('host')+""+$(location).attr('pathname')+""+$(location).attr('search'));
}
</script>
|
cs |
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
안녕하세요. 이번엔 JAVASCRIPT URL의 Parameter를 처리하는 방법을 알려드리겠습니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 |
function getParams() {
// 파라미터가 담길 배열
var param = new Array();
// 현재 페이지의 url
var url = decodeURIComponent(location.href);
// url이 encodeURIComponent 로 인코딩 되었을때는 다시 디코딩 해준다.
url = decodeURIComponent(url);
var params;
// url에서 '?' 문자 이후의 파라미터 문자열까지 자르기
params = url.substring( url.indexOf('?')+1, url.length );
// 파라미터 구분자("&") 로 분리
params = params.split("&");
// params 배열을 다시 "=" 구분자로 분리하여 param 배열에 key = value 로 담는다.
var size = params.length;
var key, value;
for(var i=0 ; i < size ; i++) {
key = params[i].split("=")[0];
value = params[i].split("=")[1];
param[key] = value;
}
return param;
}
|
cs |