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. [php] 초간단 게시판 페이지 분할 알고리즘

    Date2003.04.23 CategoryDevelop Byhooni Views10119
    Read More
  2. [c] 디피-헬만 키교환(Diffie–Hellman key exchange) 샘플 코드.. ㅋㄷ

    Date2013.04.23 CategoryDevelop Byhooni Views10129
    Read More
  3. [c] 도메인 소켓(Unix Domain Socket) UDP

    Date2013.04.23 CategoryDevelop Byhooni Views10175
    Read More
  4. [c++] MFC로 만든 디렉토리/파일 파인더

    Date2013.04.23 CategoryDevelop Byhooni Views10179
    Read More
  5. [js] jQjuery $ 활용

    Date2013.12.17 CategoryDevelop Byhooni Views10195
    Read More
  6. [ios] UUID 생성 + Key Chain 연동

    Date2016.05.13 CategoryDevelop Byhooni Views10197
    Read More
  7. [java] RGB 색상 조절 버튼.. 스윙(swing)

    Date2013.04.23 CategoryDevelop Byhooni Views10211
    Read More
  8. 다운 받아서 테스트 해볼것..

    Date2013.04.23 CategoryDevelop Byhooni Views10239
    Read More
  9. [c++] mfc이용한 트레이아이콘(TrayIcon) 클래스 예제 프로젝트

    Date2013.04.23 CategoryDevelop Byhooni Views10256
    Read More
  10. [js] jQuery 셀랙터(selector) 요약

    Date2013.12.17 CategoryDevelop Byhooni Views10273
    Read More
  11. [c] 약수/최대공약수/완전수 알고리즘

    Date2003.04.23 CategoryDevelop Byhooni Views10276
    Read More
  12. [c] 다중연결 서버 만들기 #2 - select() 사용

    Date2013.04.23 CategoryDevelop Byhooni Views10288
    Read More
Board Pagination Prev 1 ... 39 40 41 42 43 44 45 46 47 48 ... 71 Next
/ 71