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] Xcode 불필요한 캐시 삭제하기

    Date2021.10.12 CategoryDevelop Byhooni Views1811
    Read More
  2. [ios] Xcode를 사용해서 Static Library 만들기 (시뮬레이터 + 디바이스)

    Date2015.01.03 CategoryDevelop Byhooni Views3290
    Read More
  3. [ios] XCode에서 Provisioning Profile 여러개 중복될 때

    Date2014.06.26 CategoryDevelop Byhooni Views2828
    Read More
  4. [ios] Xcode에서 특정 파일만 ARC 따로 설정하는 방법

    Date2017.03.29 CategoryDevelop Byhooni Views958
    Read More
  5. [ios] Xcode의 디버그 모드에서 콜스택

    Date2015.01.03 CategoryDevelop Byhooni Views1007
    Read More
  6. [ios] 간단한 방법으로 OS버전 확인하기.

    Date2013.09.24 CategoryDevelop Byhooni Views13321
    Read More
  7. [ios] 개발 기초 가이드 링크..

    Date2013.04.23 CategoryDevelop Byhooni Views31371
    Read More
  8. [ios] 구분자로 문자열 자르기 (split)

    Date2013.04.23 CategoryDevelop Byhooni Views26274
    Read More
  9. [ios] 기본 네비게이션바의 타이틀, back버튼 위치와 속성 변경

    Date2016.05.16 CategoryDevelop Byhooni Views2099
    Read More
  10. [ios] 네트워크 인디케이터(NetworkActivityIndicator) 작동

    Date2014.01.24 CategoryDevelop Byhooni Views12494
    Read More
  11. [ios] 동영상 플레이어 샘플 (for Local File)

    Date2017.02.07 CategoryDevelop Byhooni Views1081
    Read More
  12. [ios] 동영상 플레이어 샘플 (for PIP Player)

    Date2017.03.15 CategoryDevelop Byhooni Views1274
    Read More
Board Pagination Prev 1 ... 43 44 45 46 47 48 49 50 51 52 ... 98 Next
/ 98