Gmail 용 스크립트가 있습니다. iframe은 canvas_frame
안에 있습니다.
parent.document
을 사용하여 상위 문서에 대한 핸들을 가져 오려고합니다. 그러나 크롬에서는 그것이 정의되지 않았 음을 알려줍니다. 파이어 폭스에서는 잘 작동하지만 크롬에서는 불어납니다.
그러면 Chrome에서 iframe 내에서 부모 문서에 대한 핸들을 얼마나 정확하게 얻을 수 있습니까?
크롬 버전이 부분이 바로 로그 윈도우에 끝없이 undefined
출력Chrome iframe 상위가 정의되지 않았습니다.
function init() {
try {
if(parent == null) {
console.log(typeof parent);
window.setTimeout(init, 200);
return;
}
// SOME MORE STUFF
} catch(e) { console.log(e) }
}
: 11.0.686.3
여기있어 실패 코드이다.
다음은 동일한 결과를 산출하는 테스트 스크립트입니다. 그것은 undefined
다음에 끝없이 cQ
을 출력합니다.
// ==UserScript==
// @name TEST SCRIPT FOR CHROME
// @version 1.0
// @namespace 1nfected
// @description TEST
// @include http://mail.google.com/*
// @include https://mail.google.com/*
// ==/UserScript==
(function() {
if(document.documentElement.className != 'cQ') {
console.log('not our frame');
return;
}
function init() {
if(window.parent == null) {
console.log(typeof window.parent);
console.log(document.documentElement.className);
window.setTimeout(init, 1000);
return;
}
console.log('Found the parent');
}
init();
})();
Chrome에서 사용자 스크립트가 제한적이라고하는 이유는 무엇입니까? , 콘텐츠 스크립트를 사용하면 전체 컨트롤을 갖기 때문에 더 좋아질 것입니다 (다소). –
약간의 독서를했으며 결국 code.google.com에 제출 한 문제를 발견했습니다. 나는 콘텐츠 스크립트가 좋다고 생각하지 않는다. – 1nfected