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. [mac] Homebrew/rvm/cocoapod setting

    Date2017.07.29 CategorySystem/OS Byhooni Views1010
    Read More
  2. [mac] Charlesproxy 간단한 설정 내용~

    Date2013.11.12 CategorySystem/OS Byhooni Views12337
    Read More
  3. [macos] How to Fix ‘You Shut Down Your Computer Because of a Problem’

    Date2022.06.01 CategorySystem/OS Byhooni Views800
    Read More
  4. [linux] 한글 URL 인식할 수 있게 아파치(Apache) 설정 (mod_url.c 설치)

    Date2013.04.23 CategorySystem/OS Byhooni Views13068
    Read More
  5. [linux] 프로세스의 stat 상태에 대한 설명

    Date2013.04.23 CategorySystem/OS Byhooni Views10764
    Read More
  6. [linux] 프로세스 상태확인(ps)

    Date2003.04.23 CategorySystem/OS Byhooni Views12715
    Read More
  7. [linux] 프로세스 관련 시스템콜

    Date2003.04.23 CategoryDevelop Byhooni Views7827
    Read More
  8. [linux] 프로그램 설치방법 (내공쌓기)

    Date2003.04.23 CategorySystem/OS Byhooni Views13434
    Read More
  9. [linux] 패킷의 소스 주소 바꾸기

    Date2003.04.23 CategorySystem/OS Byhooni Views18796
    Read More
  10. [linux] 패킷 스니퍼링

    Date2003.04.23 CategorySystem/OS Byhooni Views16327
    Read More
  11. [linux] 파일내 문자열 찾아 바꾸기

    Date2013.04.23 CategorySystem/OS Byhooni Views12198
    Read More
  12. [linux] 특정 문자열 포함된 파일 찾는 명령어

    Date2013.10.16 CategorySystem/OS Byhooni Views30623
    Read More
Board Pagination Prev 1 ... 21 22 23 24 25 26 27 28 29 30 ... 98 Next
/ 98