if(document.namespaces) {
//IE
document.namespaces.add("fb", "http://ogp.me/ns#");
document.namespaces.add("og", "http://ogp.me/ns/fb#");
if (typeof(console) != 'undefined' && console) {
console.log("IE: OG and FB NameSpace added");
} else {
//Other Browsers
var htmlRoot = jQuery(jQuery("html").get(0));
if(typeof(htmlRoot.attr("xmlns:fb")) == "undefined") {
htmlRoot.attr("xmlns:og",'http://ogp.me/ns#');
htmlRoot.attr("xmlns:fb",'http://ogp.me/ns/fb#');
if (typeof(console) != 'undefined' && console) {
console.log("OG and FB NameSpace added");
}
}
}
$ (document) .ready() 함수에 넣지 마십시오!
감사합니다. – CubanX
완벽하게 작동했습니다. –
비동기 적으로 Facebook을 비동기 적으로로드하고 있습니다. 예를 들어 '$ ('html ')을 통해 직접 이름 공간을 추가하는 것이 발견되었습니다. attr ('xmlns : fb ','http : // www .... ') 작동하지 않았다. 나는 지금 페이스 북의 코드를 통해 디버깅을하고 있으며,'document.namespaces'를 사용하여 네임 스페이스를 읽는 것으로 보입니다. jQuery를 통해 네임 스페이스를 추가 한 후에도 document.namespaces [ 'xmlns : fb']'는'undefined'를 반환합니다. . – ripper234