Contents

?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
outerHTML 파이어폭스(F/F)에서 쓰는 방법
outerHTML 파이어폭스(F/F)에서 쓰는 방법

<html>
<title>outerHTML 파이어폭스 대응</title>
<script>
/**************************************
* 샘플 코드 및 펑션 생성 @ 정민철
* http://tost.tistory.com
*
* 원본 참조소스
* http://snipplr.com/view/5460/outerhtml-in-firefox/
* http://www.phpschool.com/gnuboard4/bbs/
* board.php?bo_table=tipntech&wr_id=56477
***************************************/

//ff대응 outerhtml결과
function getouterHtml(obj)
{
  var html = null;
  //널처리
  if (obj == null) return null; 

  if (typeof(obj.outerHTML) == "string")
  {//스트링값을 가져온다면 IE로 가정함
    html =  obj.outerHTML;
    //alert("ie"); //디버그용
  }
  else
  {
    html = (new XMLSerializer).serializeToString(obj); 
    //alert("ff"); //디버그용
  }
  return html;
}

//ff대응 outerhtml 삽입
function setOuterHtml(obj, html)
{
  if (obj == null) return; //null처리

  if (typeof(obj.outerHTML) == "string")
  {//스트링값을 가져온다면 IE로 가정함
    //alert("ie"); //디버그용
    obj.outerHTML = html;
  }
  else
  {
    //alert("ff"); //디버그용
    var el = document.createElement('divs');
    el.innerHTML = html;
    var range = document.createRange();
    range.selectNodeContents(el);
    var documentFragment = range.extractContents();
    obj.parentNode.insertBefore(documentFragment, obj);
    obj.parentNode.removeChild(obj);
  }
}
</script>


<body>

  <divs id="test" style="background:yellow;">
    원래본문
  </divs>

  <script>
    var divsobj = document.getElementById("test");
  </script>

  <a href="javascript:alert(getouterHtml(divsobj))">
    outer값확인	
  </a>

  <a href="javascript:setOuterHtml(divsobj, 'htmltest')">
    outer값 변경
  </a>

</body>
<html>


?

  1. [ios] APNS 샘플 코드..

    Date2013.06.27 CategoryDevelop Byhooni Views0
    Read More
  2. [ios] APNS 클라이언트 구현 (pdf)

    Date2013.06.27 CategoryDevelop Byhooni Views15695
    Read More
  3. [ios] PHP로 APNS 프로바이더~

    Date2013.06.27 CategoryDevelop Byhooni Views16849
    Read More
  4. 영어 관련 토렌트

    Date2013.06.25 CategoryEtc Byhooni Views0
    Read More
  5. 영어 아주 쉬운 영작문 강의 01~60

    Date2013.06.25 CategoryEtc Byhooni Views0
    Read More
  6. 성문 종합 영어 정리된 pdf 파일

    Date2013.06.25 CategoryEtc Byhooni Views30983
    Read More
  7. 프로그래밍에서 foo, bar 함수의 유래

    Date2013.06.25 CategoryDevelop Byhooni Views21267
    Read More
  8. 영작 연습을 위한 실용영어 문장 1001개 (1~500)

    Date2013.06.21 CategoryEtc Byhooni Views30430
    Read More
  9. 여러 대학 및 권위있는 기관 강좌 모음 ㅋㅋ

    Date2013.06.17 CategoryEtc Byhooni Views15124
    Read More
  10. [ios] 패스(path) 앱 메뉴 스타일

    Date2013.06.11 CategoryDevelop Byhooni Views0
    Read More
  11. 엑셀 함수 총 정리 ㅎㅎ

    Date2013.06.05 CategoryEtc Byhooni Views24467
    Read More
  12. [ios] 스터디 자료 (from 종길M)

    Date2013.06.04 CategoryDevelop Byhooni Views0
    Read More
Board Pagination Prev 1 ... 30 31 32 33 34 35 36 37 38 39 ... 98 Next
/ 98