Views 16441 Votes 0 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
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>

?

List of Articles
No. Category Subject Author Date Views
341 System/OS [linux] 쉘 스크립트 (Shell Script) hooni 2003.04.23 12064
340 Develop [linux] 쉘 스크립트를 이용한 BBS hooni 2003.04.23 10047
339 System/OS [linux] 쉘 스크립트에 대한 설명과 예제.. hooni 2003.04.23 13413
338 System/OS [linux] 쉘 환경변수 PS1(프롬프트) hooni 2003.04.23 13492
337 System/OS [linux] 쉘스크립트 expr hooni 2014.03.11 15618
336 System/OS [linux] 스케쥴링 순서(nice) 변경하기 hooni 2003.04.23 12536
335 System/OS [linux] 시스템 데몬 종류와 설명 hooni 2013.04.23 11139
334 System/OS [linux] 아파치 설치/설정(proxy) hooni 2003.04.23 12965
333 System/OS [linux] 아파치설치/설정 hooni 2003.04.23 14492
332 System/OS [linux] 아파치설치/설정 - SSI(Server Side Include) hooni 2003.04.23 13206
331 System/OS [linux] 아파치설치/설정 - 사용인증 hooni 2003.04.23 15084
330 System/OS [linux] 아파치설치/설정 - 알리어싱(aliasing) hooni 2003.04.23 51368
329 System/OS [linux] 아파치설치/설정(CGI부분) hooni 2003.04.23 14568
328 System/OS [linux] 아파치설치/설정(모니터링) hooni 2003.04.23 14153
327 System/OS [linux] 우분투 APM + phpmyadmin 설치 hooni 2013.10.07 49321
326 System/OS [linux] 웹로그분석기(webalizer) 설치 & 팁 hooni 2003.04.23 14882
Board Pagination Prev 1 ... 51 52 53 54 55 ... 74 Next
/ 74