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. [js] 파이어폭스(Firefox;F/F)에서 outerHTML 작동하도록 만든 메소드

    Date2013.04.23 CategoryDevelop Byhooni Views16441
    Read More
  2. 개발자가 알아야할 10가지 보안팁으로 코드 보호하기

    Date2013.04.23 CategoryEtc Byhooni Views16403
    Read More
  3. 프로그램 문서 관리 (Doxygen)

    Date2013.04.23 CategoryDevelop Byhooni Views16385
    Read More
  4. [linux] 메타(기호)문자의 의미와 사용

    Date2003.04.23 CategorySystem/OS Byhooni Views16381
    Read More
  5. [linux] 콘솔/Xwindow 에서 PC스피커 소리 없애기

    Date2003.04.23 CategorySystem/OS Byhooni Views16352
    Read More
  6. [php] 싸이월드 이미지 외부 링크 하기(php)

    Date2013.04.23 CategoryEtc Byhooni Views16351
    Read More
  7. [android] 안드로이드 어플 모음 ㅎㅎ

    Date2013.04.23 CategoryDevelop Byhooni Views16340
    Read More
  8. [linux] 패킷 스니퍼링

    Date2003.04.23 CategorySystem/OS Byhooni Views16313
    Read More
  9. [windows] 원격 데스크탑(터미널 서비스) 포트 변경

    Date2013.04.23 CategorySystem/OS Byhooni Views16304
    Read More
  10. [c++] p.58 연습문제 2번

    Date2003.04.23 CategoryDevelop Byhooni Views16296
    Read More
  11. [flash] 페이지 이동 (액션스크립트)

    Date2013.04.23 CategoryEtc Byhooni Views16263
    Read More
  12. [c] 네트워크 정보 알아보기

    Date2013.04.23 CategoryDevelop Byhooni Views16122
    Read More
Board Pagination Prev 1 ... 16 17 18 19 20 21 22 23 24 25 ... 98 Next
/ 98