2009-11-15 6 views
7

필자는이 점에 대해 도움이 절실하다.Internet Explorer 또는 Opera에서이 JavaScript (document.open 및 document.write 사용)가 작동하지 않는 이유는 무엇입니까?

나는 밀접하게 평행, 그리고 문제, 내가 다른 곳에서 작성한 다른 더 복잡한 < 스크립트 >를 재현 < 스크립트 >를 만들었습니다. 여기

은 무엇이다 :

  • 가 < iframe을 >를 생성하고 페이지
  • 생성에 <DIV>로의 삽입과 < 스크립트를 포함하는 < iframe을 >에 문서를 추가 > (AJAX를 사용하여 < 스크립트 >을로드하는 콜백 함수 및 함수 포함)
  • 후자의 외부 스크립트는 문서를 만들고 iframe >이 들어있는 <에 추가하는 함수를 호출하는 콜백 함수를 호출하는 것입니다. 이 효과적으로 < 스크립트를 덮어 쓰기한다 >

관련된 세 개의 파일은 다음과 같습니다

이 모든 기능은 Firefox, Safari 및 Chrome에서 작동합니다. 인터넷 익스플로러와 오페라가 고장난 곳입니다. main.js의 render() 함수가 실행되고 세 가지 경고가 모두 발생하지만 <iframe>의 문서를 덮어 쓰지 않습니다. 나는 어떤 문서가 작성되고 쓰여지는지, 또는 어떤 문서가 작성되었는지를 말할 수 없다.

render() 함수 시작 부분에 디버그 코드 (예 : console.log (document))를 추가하면 작동중인 브라우저는 기존 <iframe> 문서를 처리하고 아래에 포함 된 속성을 나열하는 것처럼 보입니다. Internet Explorer도 일종의 문서를 찾은 것으로 보입니다. 왜 내가 그것을 덮어 씌우지 않는지 말할 수 없다.

범위의 문제 일 수 있습니까? 어쩌면 내가 document.write(), document.open() 또는 document.close() 메소드를 부적절하게 사용하고 있으며, Firefox와 몇 가지 다른 브라우저가 나를 버리게 할 것입니까?

하나의 가능한 단서 : 렌더링() 기능을 사용하지 않으면 (즉, main.js에서 load() 이후에 넣으면) 정상적으로 작동합니다. 이는 나에게 document.open() 등을 사용하는 것이 아니라 callback() 함수가 실행될 때까지 문서 객체를 사용할 수 없거나 범위를 벗어 났음을 의미합니다. 또는 그런 것.

이것은 완전히 어려움을 겪었으며 마감일이 임박한 매우 중요한 프로젝트입니다. 내가이 잼에서 벗어나면 해킹이나 해결 방법을 넘지 않습니다. 어떤 도움이나 통찰력도 극도로 높이 평가 될 것입니다!문서 속성의

을 console.log()의 목록 : 당신은 "src" 속성으로 iframe을의 내용을로드해야

ATTRIBUTE_NODE: 2 
CDATA_SECTION_NODE: 4 
COMMENT_NODE: 8 
DOCUMENT_FRAGMENT_NODE: 11 
DOCUMENT_NODE: 9 
DOCUMENT_POSITION_CONTAINED_BY: 16 
DOCUMENT_POSITION_CONTAINS: 8 
DOCUMENT_POSITION_DISCONNECTED: 1 
DOCUMENT_POSITION_FOLLOWING: 4 
DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 32 
DOCUMENT_POSITION_PRECEDING: 2 
DOCUMENT_TYPE_NODE: 10 
ELEMENT_NODE: 1 
ENTITY_NODE: 6 
ENTITY_REFERENCE_NODE: 5 
NOTATION_NODE: 12 
PROCESSING_INSTRUCTION_NODE: 7 
TEXT_NODE: 3 
URL: "http://localhost/projects/test/ajax_loader/document_write/index.html" 
activeElement: HTMLBodyElement 
addEventListener: function addEventListener() { 
adoptNode: function adoptNode() { 
alinkColor: "" 
all: HTMLCollection 
anchors: HTMLCollection 
appendChild: function appendChild() { 
applets: HTMLCollection 
attributes: null 
baseURI: "http://localhost/projects/test/ajax_loader/document_write/index.html" 
bgColor: "" 
body: HTMLBodyElement 
captureEvents: function captureEvents() { 
characterSet: "UTF-8" 
charset: "UTF-8" 
childNodes: NodeList 
clear: function clear() { 
cloneNode: function cloneNode() { 
close: function close() { 
compareDocumentPosition: function compareDocumentPosition() { 
compatMode: "BackCompat" 
cookie: "__gads=ID=62bb88ab20ac9451:T=1256683145:S=ALNI_Mbso-nFjAvRzYhCSwhiuaDh84G8CA" 
createAttribute: function createAttribute() { 
createAttributeNS: function createAttributeNS() { 
createCDATASection: function createCDATASection() { 
createComment: function createComment() { 
createDocumentFragment: function createDocumentFragment() { 
createElement: function createElement() { 
createElementNS: function createElementNS() { 
createEntityReference: function createEntityReference() { 
createEvent: function createEvent() { 
createExpression: function createExpression() { 
createNSResolver: function createNSResolver() { 
createNodeIterator: function createNodeIterator() { 
createProcessingInstruction: function createProcessingInstruction() { 
createRange: function createRange() { 
createTextNode: function createTextNode() { 
createTreeWalker: function createTreeWalker() { 
defaultCharset: "iso-8859-1" 
defaultView: DOMWindow 
designMode: "off" 
dir: "" 
dispatchEvent: function dispatchEvent() { 
doctype: null 
documentElement: HTMLHtmlElement 
documentURI: "http://localhost/projects/test/ajax_loader/document_write/index.html" 
domain: "localhost" 
elementFromPoint: function elementFromPoint() { 
embeds: HTMLCollection 
evaluate: function evaluate() { 
execCommand: function execCommand() { 
fgColor: "" 
firstChild: HTMLHtmlElement 
forms: HTMLCollection 
getCSSCanvasContext: function getCSSCanvasContext() { 
getElementById: function getElementById() { 
getElementsByClassName: function getElementsByClassName() { 
getElementsByName: function getElementsByName() { 
getElementsByTagName: function getElementsByTagName() { 
getElementsByTagNameNS: function getElementsByTagNameNS() { 
getOverrideStyle: function getOverrideStyle() { 
getSelection: function getSelection() { 
hasAttributes: function hasAttributes() { 
hasChildNodes: function hasChildNodes() { 
hasFocus: function hasFocus() { 
height: 150 
images: HTMLCollection 
implementation: DOMImplementation 
importNode: function importNode() { 
inputEncoding: "UTF-8" 
insertBefore: function insertBefore() { 
isDefaultNamespace: function isDefaultNamespace() { 
isEqualNode: function isEqualNode() { 
isSameNode: function isSameNode() { 
isSupported: function isSupported() { 
jQuery1258269389622: 2 
lastChild: HTMLHtmlElement 
lastModified: "" 
linkColor: "" 
links: HTMLCollection 
localName: null 
location: Location 
lookupNamespaceURI: function lookupNamespaceURI() { 
lookupPrefix: function lookupPrefix() { 
namespaceURI: null 
nextSibling: null 
nodeName: "#document" 
nodeType: 9 
nodeValue: null 
normalize: function normalize() { 
open: function open() { 
ownerDocument: null 
parentElement: null 
parentNode: null 
plugins: HTMLCollection 
preferredStylesheetSet: null 
prefix: null 
previousSibling: null 
queryCommandEnabled: function queryCommandEnabled() { 
queryCommandIndeterm: function queryCommandIndeterm() { 
queryCommandState: function queryCommandState() { 
queryCommandSupported: function queryCommandSupported() { 
queryCommandValue: function queryCommandValue() { 
querySelector: function querySelector() { 
querySelectorAll: function querySelectorAll() { 
readyState: "complete" 
referrer: "http://localhost/projects/test/ajax_loader/document_write/index.html" 
releaseEvents: function releaseEvents() { 
removeChild: function removeChild() { 
removeEventListener: function removeEventListener() { 
replaceChild: function replaceChild() { 
scripts: HTMLCollection 
selectedStylesheetSet: null 
styleSheets: StyleSheetList 
textContent: null 
title: " Page" 
vlinkColor: "" 
width: 300 
write: function write() { 
writeln: function writeln() { 
xmlEncoding: null 
xmlStandalone: false 
xmlVersion: null
+0

오류가 있습니까? –

+0

안녕하세요 - Internet Explorer 나 Opera에서 오류가 표시되지 않습니다. 둘 다 render() 함수에 alert()를 표시하지만