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. git 브런치 배우기 (링크)

    Date2013.07.09 CategoryDevelop Byhooni Views22085
    Read More
  2. GCM 사용하기 3 (JSP로 GCM 푸시 서버 만들기)

    Date2013.07.06 CategoryDevelop Byhooni Views27141
    Read More
  3. GCM 사용하기 2 (단말에 GCM 구현하기)

    Date2013.07.06 CategoryDevelop Byhooni Views24660
    Read More
  4. [android] GCM 사용하기 1 (GCM 서비스 신청하기)

    Date2013.07.06 CategoryDevelop Byhooni Views52530
    Read More
  5. [ios] APNS 샘플 코드..

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

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

    Date2013.06.27 CategoryDevelop Byhooni Views17945
    Read More
  8. 영어 관련 토렌트

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

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

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

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

    Date2013.06.21 CategoryEtc Byhooni Views32064
    Read More
Board Pagination Prev 1 ... 30 31 32 33 34 35 36 37 38 39 ... 99 Next
/ 99