| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
| 28 | 29 | 30 | 31 |
- JavaScript
- IntelliJ
- Tomcat
- 설정
- JDBC
- ubuntu
- AJAX
- SpringBoot
- Thymeleaf
- Python
- PostgreSQL
- myBatis
- git
- Eclipse
- MSSQL
- Docker
- Source
- error
- 문서
- 오픈소스
- Open Source
- spring
- jpa
- maven
- Exception
- Spring Boot
- Core Java
- oracle
- STS
- MySQL
- Today
- Total
헤르메스 LIFE
[Javascript] Function 모음. 본문
|
//백스페이스 방지. 2015.10.20 추가. $(document).keydown(function(e){ if(e.target.nodeName != "INPUT" && e.target.nodeName != "TEXTAREA" ){ if(e.keyCode === 8){ return false ; } } }); |
|
/* FireFox는 window.event가 없어서 추가 */ if($.browser.mozilla){ $.each(["mousedown", "mouseover", "mouseout", "mousemove", "mousedrag", "click", "dblclick"], function(i, eventName){ window.addEventListener(eventName, function (e){ window.event = e; }); }); } |
|
function isIE() { if( navigator.userAgent.indexOf( "MSIE")>=0 || navigator.userAgent.indexOf( "Trident")>=0) return true ; else return false ; } |
|
/** * Escape 문자 -> HTML * .replace(/&/g, '&').replace(/>/g, '>').replace(/< /g, '<').replace(/\n/g, '<br>' ).replace(/ /g, ' ')); */ var entityMap = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'", "/": "/", " ": " " };
function escapeHtml(string) { return String(string).replace(/[& <>"'\/]/g, function (s) { return entityMap[s]; }); } |
|
//yyyymmdd 형태로 포매팅된 날짜 반환 Date.prototype.yyyymmdd = function() { var yyyy = this.getFullYear().toString(); var mm = ( this.getMonth() + 1).toString(); var dd = this.getDate().toString();
return yyyy + (mm[1] ? mm : '0'+mm[0]) + (dd[1] ? dd : '0' +dd[0]); }
console.log((new Date()).yyyymmdd()); |
|
/** * replaceAll 구현 */ function replaceAll(sValue, param1, param2) { return sValue.split(param1).join(param2); }
// replaceAll prototype 추가 String.prototype.replaceAll = function () { var a = arguments, length = a.length; if ( length == 0 ) { return this ; } var regExp = new RegExp( a[0], "g" ); if ( length == 1 ) { return this .replace(regExp, ""); } else { return this .replace(regExp, a[1]); } return this ; }; |
'JSP&JavaScript&HTML' 카테고리의 다른 글
| [Javascript] setTimeout (1) | 2020.12.02 |
|---|---|
| [HTML] HTML 특수문자 코드표 (0) | 2020.12.02 |
| [Javascript] Console.log 익스플로어(IE)에서 사용하기 (0) | 2020.12.02 |
| [Javascript] 날짜 오늘, 이번주, 이번달 (0) | 2020.12.02 |
| [jQuery] serializeObject (0) | 2020.11.20 |