에 보안 오류 1000가 발생 나는 그것이 짧은 만들 수 있습니다 :
내가 객체 반사 코드의 어떤 종류를 만들기위한 window
객체의 내부에 사용 가능한 모든 기능과 객체를 열거 형 싶다.
Firefox에서는 모든 브라우저에서 정상적으로 실행됩니다. 여기 내 의사 루프 코드 :파이어 폭스는이 간단한 열거
var all_names=[];
for (var i in window)
{
//if it's NOT an object
all_name.push(i.toString());
//if it's an object
enum up to 3 more levels in child objects.
}
그리고 나는 그런 getOwnPropertyNames
파이어 폭스에서 사용 가능한 API를 사용하지 않습니다.
그럼 어떻게해야합니까? 자바 스크립트의 열거에 대한 더 나은 솔루션 (물론 크로스 브라우저) 여기
좀 더 기술적 인 정보가된다 :
정확한 파이어 폭스 오류 :
[20:48:04.539] uncaught exception: [Exception... "Security error" code: "1000" nsresult: "0x805303e8 (NS_ERROR_DOM_SECURITY_ERR)" location: "http://localhost/test/common.js Line: 53"]
정확한 열거 형 루프 코드 : 내가 페이지에 iframe이를 열어 비슷한 짓을
function reflectAsString() {
try{
var m1 = "";
var m2 = "";
var m3 = "";
for (var i in window) {
if(window[i] && window[i]!= null && window[i] != "globalStorage")
{
m1 += i;
first_instance = window[i];
if(typeof first_instance == "object")
{
for(var j in first_instance)
{
if(first_instance[j] && first_instance[j]!= null)
{
m2 += j;
second_instance = first_instance[j];
if(typeof second_instance == "object")
{
for (var k in second_instance)
{
if(second_instance[k] && second_instance[k]!= null)
{
m3 += k;
}
}
}
}
}
}
}
}
return hex_md5(hex_md5(m1)+hex_md5(m2)+hex_md5(m3));
} catch(e) {
try {
var strToHash = Object.getOwnPropertyNames(window).filter(function(property) {
return typeof window[property] == 'function';
});
return hex_md5(strToHash.toString());
} catch(e2) {
return "undef";
}
}
}
알아 내기 위해 너무 열심히해서는 안됩니다 * 알이 오류의 원인이된다. 그렇게하면 문제를 해결하거나 문제를 해결할 수있는 충분한 정보를 얻을 수 있습니다. –
@KirkWoll 나는 globalStorage가 더 이상 사용되지 않으며 이와 같이 액세스하면 이러한 오류가 발생할 것이라고 생각합니다. – Sepehr