Sep 102012
 

예전에는 HTML 작업이 단순했지만, jQuery, Ajax등을 사용하면서 복잡한 Javascript을 많이 사용하게 되었습니다. 개발을 하게 되면 무엇보다 개발환경을 잘 파악해서 활용하는 것이 중요합니다.

대부분 작업을 Chrome에서 작업을 하면서 debug를 하지만, 브라우저 호환성을 위해서 IE에서 확인을 해야 합니다. 하지만 IE에서 debug 를 사용하게 되면 자주 응답없음 이라는 문구를 만나면서 debug를 하기 힘든 상황이 많이 발생합니다.
이런 경우에는 어쩔수 없이 원시적으로 alert() 혹은 log를 출력해서 확인을 해야 합니다.

하지만 IE에서 console.log를 사용하게 되면 오류가 발생하기 때문에 아래와 같은 방법을 사용하면 됩니다.

확인을 하고자 하는 페이지에서 F12을 눌러서 개발자 도구를 실행합니다. 그리고 스크립트 탭을 선택을 한 다음에 페이지를 재로딩을 하게 되면 console.log 를 사용할수 있으며, 해당 로그가 콘솔에 출력되는 것을 확인할 수 있습니다.

그리고 오류를 방지하기 위해서 아래와 같은 코드로 출력을 하게 되면 개발자도구가 비활성화 되었을때에도 오류를 발생시키지 않게 된다.

 
    if(typeof console != 'undefined') { console.log("debug message"); }

참고 URL : http://stackoverflow.com/questions/690251/what-happened-to-console-log-in-ie8

Print Friendly

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/smlee/blog/wordpress/wp-content/plugins/seo-facebook-comments/seofacebook.php on line 488

Warning: Invalid argument supplied for foreach() in /home/smlee/blog/wordpress/wp-content/plugins/seo-facebook-comments/seofacebook.php on line 490

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Plugin from the creators of Brindes :: More at Plulz Wordpress Plugins