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] 아이폰용 앱 오픈 소스들

    Date2013.04.23 CategoryDevelop Byhooni Views488567
    Read More
  2. [ios] 언어, 지역, 국가 설정 가져오기

    Date2014.05.12 CategoryDevelop Byhooni Views291045
    Read More
  3. 자주 쓰는 Docker 명령어 alias

    Date2020.01.10 CategoryDevelop Byhooni Views289748
    Read More
  4. 베지어 곡선 (Bezier curve)

    Date2013.08.18 CategoryEtc Byhooni Views239094
    Read More
  5. [ios] Start developing your navigation app for CarPlay without enrollment

    Date2020.02.22 CategoryDevelop Byhooni Views132877
    Read More
  6. [link] 유용한 사이트 링크.

    Date2013.08.19 CategoryEtc Byhooni Views131284
    Read More
  7. [android] 만화 어플 소스코드

    Date2013.04.23 CategoryDevelop Byhooni Views96727
    Read More
  8. 디피헬만(Diffie-Hellman) 초간단 개념..

    Date2013.04.23 CategoryAlgorithm Byhooni Views85687
    Read More
  9. [c#] Hashtable <-> Json (dll 포함)

    Date2013.04.23 CategoryDevelop Byhooni Views84626
    Read More
  10. 레고 마인드스톰 NXT 수도쿠, 큐브 소스코드..

    Date2013.04.23 CategoryDevelop Byhooni Views83102
    Read More
  11. [android] 점심 해결 앱 소스 코드 ㅋㅋ

    Date2013.04.23 CategoryDevelop Byhooni Views81374
    Read More
  12. [C#] MD5, SHA1 해시 & 인코딩

    Date2013.04.23 CategoryDevelop Byhooni Views80948
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 99 Next
/ 99