window.location, URL에서 값 가져오기 Posted on 2015년 4월 16일 by hsmtree Server side 외에도 Client side에서 URL Query Parameter를 가져와야 하는 경우가 가끔 있다. 필요할 때 꺼내 쓸 수 있게 정리해 봤다. prototype.js에는 이런 Parameter를 가져오는 method가 있으나 그런 플러그인을 사용하지 않고 값을 가져오는 방식이다. 1. DOM URL = https://http://www.google.co.kr/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=html5 alert(window.location.hash); // "#q=html5" alert(window.lo..
seq oeeRate status keepSecond
1. 선택한 요소의 크기를 알 수 있는 방법$(Selecter).outerWidth();$(Selecter).outerHeight();// 인자로 true 전달하면 요소의 마진 크기까지 알 수 있다.$("article.clist-group").outerWidth(true); $("article.clist-group").outerHeight(true);2. 마진의 크기까지 필요가 없다면 $(Selecter).wdth();$(Selecter).height();
상속하는 방법 1. 생성자 함수를 정의해서 상속하는 방법 // 부모 생성자 함수 정의 var Mammal = function(name){ this.name = name; }; Mammal.prototype.get_name = function(){ return this.name; }; Mammal.prototype.says = function(){ return this.saying || ''; }; //자식 생성자 함수 정의var Cat = function(name){ this.name = name; this.saying = 'meow'; }; Cat.prototype = new Mammal(); //
// 객체 정의 시작 var Person = function(name, age){ this.name = name; this.age = age; }; Person.prototype.say = function(){//prototype영역, 공유영역 console.log(this.name); }; //객체 정의 종료 var jin = new Person('jin', '19');//인스턴스(객체) 생성 var jong = new Person('jong', '24'); // jin.say(); // jong.say(); // console.dir(jin);// constructor is Person var literalObj = {};// 인스턴스(객체) 생성 // console.dir(literalObj ); ..
함수호출 방식에 따른 this의 바인딩에 대해서... 더글라스 크락포드의 자바스크립트 핵심 가이드를 공부하면서 Javascript에는 4가지 함수호출 패턴이 있다는 것을 알게 되었고 이 패턴에 따라서 함수내의 this의 값은 달라지게 됩니다. Javascript에서 this와 객체의 바인딩은 호출시에 일어납니다. 메서드 호출패턴함수 호출패턴생성자 호출패턴apply 호출패턴Javascript에서 this의 바인딩은 다룰때마가 헷갈리는 문제이므로 기본이 되는 내용을 공부한 김에 정리해 둡니다. 메서드 호출 패턴 여기서 메서드는 함수가 객체의 속성(멤버함수)로 저장되어 있는 경우에 이 함수를 메서드라고 부르고 메서드를 호출할때 this는 객체에 바인딩 됩니다. JavaScript var test = { x: ..