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] Debug Extensions (from 종길 차장님 ㅋㅋ)

    Date2013.04.23 CategoryDevelop Byhooni Views18908
    Read More
  2. [c#] 정규표현식을 이용한 문자열에서 태그 제거함수

    Date2013.04.23 CategoryDevelop Byhooni Views18818
    Read More
  3. [ios] 자주 쓰는 패턴과 API

    Date2013.04.23 CategoryDevelop Byhooni Views18428
    Read More
  4. [c] 팩토리얼 서버/클라이언트..

    Date2003.04.23 CategoryDevelop Byhooni Views18269
    Read More
  5. [java] 입출력 스트림 1부 (문자)

    Date2013.04.23 CategoryDevelop Byhooni Views18154
    Read More
  6. [c] ICMP 패킷을 이용한 장난감

    Date2003.04.23 CategoryDevelop Byhooni Views18127
    Read More
  7. [c++] 문자열 뒤집기(문자열 거꾸로 출력)

    Date2013.04.23 CategoryDevelop Byhooni Views18079
    Read More
  8. [unix] 쉘 스크립트 예제 모음

    Date2003.04.23 CategoryDevelop Byhooni Views17977
    Read More
  9. [winmobile] 윈도우 모바일 간단한 테스트 코드 ㅋㅋ

    Date2013.04.23 CategoryDevelop Byhooni Views17956
    Read More
  10. [ios] PHP로 APNS 프로바이더~

    Date2013.06.27 CategoryDevelop Byhooni Views17944
    Read More
  11. 프로그래밍 소스 관련 사이트..

    Date2013.04.23 CategoryDevelop Byhooni Views17902
    Read More
  12. 프로그램 문서 관리 (Doxygen)

    Date2013.04.23 CategoryDevelop Byhooni Views17837
    Read More
Board Pagination Prev 1 ... 7 8 9 10 11 12 13 14 15 16 ... 71 Next
/ 71