- XHTML 모드에서 동작하지 않습니다.
- document.write를 써서 추가된 코드는 API를 사용하여 접근할 수 있는 방법이 없습니다.
- document.write는 HTML을 노드로 보지 않고 Serialized text로 보는 전혀 다른 관점을 지니고 있습니다.(DOM하고 비교했을 때)
- 호출할 javascript코드를 페이지에 삽입합니다.
<scrip type="text/javascript" id="syndication" src="syndication.js"></script> - syndication.js에 다음의 코드를 추가합니다.
// 삽입할 태그를 DOM을 이용해서 생성합니다.
var newContent = document.createElement('p');
newContent.id = 'syndicated-content';
newContent.appendChild(document.createTextNode('Here is some syndicated content.'));
var source = document.getElementById('syndication');
// script태그의 바로 앞쪽에 newContent를 삽입하게 합니다.
source.parentNode.insertBefore(newContent, source);
출처: Insert in place without document.write via Simon Willison’s Weblog
제목에 있는 삽입하기를 삽질하기로 봤다 ㅋㅋㅋ.
답글삭제@박서은 - 2007/07/23 02:08
답글삭제^^;;;; 삽질도 많이 한답니다. ㅋ