IBM®
메인 컨텐츠로 가기
    Korea [국가변경]    이용약관
 
 
   
        제품    서비스 & 솔루션    고객지원 & 다운로드    회원 서비스    
한국 developerWorks >  웹 개발  >  포럼  >  0. 메인 포럼  >  developerWorks

IE7에서 AJAX 코드를 실행하다가 입니다    이 글의 최신 메시지를 받기 위해 귀하의 RSS 리더기를 지정하십시오.


     

 
 

나의 developerWorks
 환영 손님
로그인 또는 등록
Permlink 답변: 0 - 페이지: 1
Justme

게시: 1
등록: 2008/03/27 05:38:22 오전
IE7에서 AJAX 코드를 실행하다가 입니다
게시: 2008/03/27 06:11:55 오전
Click to report abuse   이 글에 답변하기 클릭 답변
안녕하세요. 많은 도움 부탁드립니다.
제가 다음의 javascript 코드를 IE7에서 실행했는데 문제가 생겼습니다.

function test() {

// These first two lines get the DOM tree for the current Web page,

// and then the <html> element for that DOM tree

var myDocument = document;

var htmlElement = myDocument.documentElement;

 

// What's the name of the <html> element? "html"

alert("The root element of the page is " + htmlElement.nodeName);

 

// Look for the <head> element

var headElement = htmlElement.getElementsByTagName("head")[0];

if (headElement != null) {

alert("We found the head element, named " + headElement.nodeName);

// Print out the title of the page

var titleElement = headElement.getElementsByTagName("title")[0];

if (titleElement != null) {

// The text will be the first child node of the <title> element

var titleText = titleElement.firstChild;
//alert(titleText);

// We can get the text of the text node with nodeValue

alert("The page title is '" + titleText.nodeValue + "'");

}

// After <head> is <body>

var bodyElement = headElement.nextSibling;

while (bodyElement.nodeName.toLowerCase() != "body") {

bodyElement = bodyElement.nextSibling;

}

 

// We found the <body> element...

 

// Remove all the top-level elements in the body

if (bodyElement.hasChildNodes()) {

for (i=0; i<bodyElement.childNodes.length; i++) {</p>

var currentNode = bodyElement.childNodes;

if (currentNode.nodeName.toLowerCase() == "img") {

bodyElement.removeChild(currentNode);

}

}

}

}

}

제 보기에는 titleText.nodeValue 에 홈페이지의 타이틀이 나와야 할것 같은데 도대체 답이 나오지 않습니다.
원인 좀 설명해 주세요.


모든 포럼의 최근 메시지를 받기 위해 귀하의 RSS 리더기를 지정하십시오.

    IBM 소개 개인정보 보호정책 문의