조회 수 20154 추천 수 0 댓글 0
?

단축키

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. OPT와 CAS에 대한 자료.. (교수님 메일로 보내드린 자료..)

    Date2013.04.23 CategoryDevelop Byhooni Views15066
    Read More
  2. [linux] ssh에서 원격 파일 전송하기..

    Date2013.04.23 CategorySystem/OS Byhooni Views15047
    Read More
  3. [linux] ipchains 사용예(패킷 필터링)

    Date2003.04.23 CategorySystem/OS Byhooni Views15018
    Read More
  4. [c++] mfc 간단한 파일 입출력 예제

    Date2013.04.23 CategoryDevelop Byhooni Views14998
    Read More
  5. [linux] 아파치설치/설정(모니터링)

    Date2003.04.23 CategorySystem/OS Byhooni Views14940
    Read More
  6. 스터디 자료, 암호화에 대해서.. 나중에 볼 ppt..

    Date2013.04.23 CategoryAlgorithm Byhooni Views14913
    Read More
  7. [linux] 기본적인 설정하기(내공쌓기)

    Date2003.04.23 CategorySystem/OS Byhooni Views14861
    Read More
  8. [jsp] Get방식, Post방식 전송 예제..

    Date2003.04.23 CategoryDevelop Byhooni Views14841
    Read More
  9. [js] window.open() 속성 사용 방법

    Date2013.11.18 CategoryDevelop Byhooni Views14822
    Read More
  10. [c] 기본 자료형(int)이 표현할 수 없는 큰 수(Big number)를 덧셈하는 코드.

    Date2013.04.23 CategoryDevelop Byhooni Views14791
    Read More
  11. [doc] 방송통신공학회 논문지(학술대회)

    Date2013.04.23 CategoryPPT Byhooni Views14753
    Read More
  12. 아파치(Apache) 인증사용(htaccess)으로 특정 디렉토리에 암호걸기

    Date2013.04.23 CategorySystem/OS Byhooni Views14737
    Read More
  13. [linux] 새 하드디스크 추가하기..(내공쌓기)

    Date2003.04.23 CategorySystem/OS Byhooni Views14694
    Read More
  14. [linux] 쉘 환경변수 PS1(프롬프트)

    Date2003.04.23 CategorySystem/OS Byhooni Views14617
    Read More
  15. [linux] 터미널에서 문자 깨질 때 설정 ㅋㅋ

    Date2003.04.23 CategorySystem/OS Byhooni Views14612
    Read More
  16. [ios] 간단한 방법으로 OS버전 확인하기.

    Date2013.09.24 CategoryDevelop Byhooni Views14550
    Read More
Board Pagination Prev 1 ... 19 20 21 22 23 ... 74 Next
/ 74