목록Javascript (10)
4번독수리의 둥지
Use var, it reduces the scope of the variable otherwise the variable looks up to the nearest closure searching for a var statement. If it cannot find a var then it is global (if you are in a strict mode, using strict, global variables throw an error). This can lead to problems like the following.function f (){ for (i=0; i
http://stackoverflow.com/questions/4249648/jquery-get-mouse-position-within-an-element
http://stackoverflow.com/questions/1802936/stop-all-active-ajax-requests-in-jquery http://stackoverflow.com/questions/3031572/checking-jquery-ajax-request-status
http://stackoverflow.com/questions/10418644/creating-an-iframe-with-given-html-dynamically
http://stackoverflow.com/questions/6066890/a-onclick-causes-is-not-a-function-in-ff-but-ie-ok
상황 - 본문 column 너비를 css class에 픽셀로 정해놓았는데 column 너비값을 컨텐츠(iframe으로 되어 있는 등)너비를 받아와서 동적으로 바꿔야 하는 상황 -> 해당 class의 width를 받아온 width로 overriding 하고 싶은 것이다. .column { width: 700px; } /* 원래 있던 css 설정 */ .column { width: 1203px; } /* 받아온 컨텐츠 너비값을 가져다 이렇게 밑에 추가하고 싶다. */ var s; for ( var i = 0; i < document.styleSheets.length; i++ ) { if ( document.styleSheets[i].href.indexOf('stylesheet.css') != -1 ) { s..
true && undefined = undefined true || undefined = true false && undefined = false false || undefined = undefined 4번째 충격과 공포..
give me a tooltip I`m a tooltip function showTooltip() { // somehow show tooltip } function hideTooltip { // somehow hide tooltip } function moveTooltip(event) { var x = event.clientX; var y = event.clientY; if ( browser is Chrome ) { target.style.left = x; target.style.top = y; } else if ( browser is IE ) { target.style.posLeft = x; target.style.posTop = y; } } * IE, Chrome에서는 event 객체를 잘 사용할 수..
IE has a problem replacing TBODY contents with innerHTML. The jQuery given above works; if you are not using jQuery, another solution is to have a somewhere in the page - when the response arrives, put the value with a surrounding tag into the hidden div, then use the DOM to remove the old contents from your visible tag and insert the elements from the hidden tag 1 by 1:var a=document.getElement..
for ( var i in Btns ) 따위로 순회하면서 처리하는 foreach 스타일을 좋아하는데, Array.prototype대상이 배열인데도 i에 0,1, ... 따위가 아니라 객체의 property의 key값도 포함되면서 예기치 않은 동작을 하는 것을 확인 function foo( arg1 ) { var args = Array.prototype.slice.call(arguments, 1); for ( var i in args ) { var arg = args[i]; // Do something } };