हमारे पास हमारे आईफ्रेम में पृष्ठ हैं जो पृष्ठ पर सामग्री जोड़ते हैं और फिर उपयोगकर्ता को पृष्ठ के भीतर सामग्री को रीफ्रेश करने की अनुमति देते हैं। इन मामलों में, हमने वही चीज़ देखी, जहां उपयुक्त होने पर सामग्री कम नहीं होगी।
एफबी.कैनवास।setSize() कॉल _computeContentSize है, जो नीचे दिखाया गया है:
_computeContentSize: function() {
var body = document.body,
docElement = document.documentElement,
right = 0,
bottom = Math.max(
Math.max(body.offsetHeight, body.scrollHeight) +
body.offsetTop,
Math.max(docElement.offsetHeight, docElement.scrollHeight) +
docElement.offsetTop);
if (body.offsetWidth < body.scrollWidth) {
right = body.scrollWidth + body.offsetLeft;
} else {
FB.Array.forEach(body.childNodes, function(child) {
var childRight = child.offsetWidth + child.offsetLeft;
if (childRight > right) {
right = childRight;
}
});
}
if (docElement.clientLeft > 0) {
right += (docElement.clientLeft * 2);
}
if (docElement.clientTop > 0) {
bottom += (docElement.clientTop * 2);
}
return {height: bottom, width: right};
},
समस्याग्रस्त लाइन यहाँ है:
bottom = Math.max(
Math.max(body.offsetHeight, body.scrollHeight) +
body.offsetTop,
Math.max(docElement.offsetHeight, docElement.scrollHeight) +
docElement.offsetTop);
यहां तक कि अगर आपके iframe के भीतर सामग्री सिकुड़ गई है, body.offsetHeight का मूल्य हटना नहीं होगा ।
function rfComputeContentSize() {
var body = document.body,
docElement = document.documentElement,
right = 0,
bottom = Math.max(docElement.offsetHeight, docElement.scrollHeight) + docElement.offsetTop;
if (body.offsetWidth < body.scrollWidth) {
right = body.scrollWidth + body.offsetLeft;
} else {
FB.Array.forEach(body.childNodes, function(child) {
var childRight = child.offsetWidth + child.offsetLeft;
if (childRight > right) {
right = childRight;
}
});
}
if (docElement.clientLeft > 0) {
right += (docElement.clientLeft * 2);
}
if (docElement.clientTop > 0) {
bottom += (docElement.clientTop * 2);
}
return {height: bottom, width: right};
}
कभी भी हम आकार बदलने और पता सामग्री हटना सकता है कि हम आपको चाहते हैं:
इस का समाधान करने के लिए, हम चाहते हैं कि केवल ऊंचाई के लिए docElement सलाह भी लेता है, तो जैसे computeContentSize समारोह के एक कस्टम संस्करण बनाया कस्टम फ़ंक्शन का उपयोग करने के लिए सामग्री setSize पारित करने के लिए (जैसे FB.Canvas.setSize (rfComputeContentSize())), और किसी भी समय हम जानते हैं कि सामग्री केवल बढ़ेगा, हम मानक FB.Canvas.setSize() फ़ंक्शन का उपयोग करेंगे।
ध्यान दें कि हम setAutoGrow() का उपयोग कर रहे थे और मैं जाँच नहीं था, लेकिन यह सोचते हैं कि यह एक ही समारोह का उपयोग करता है आकार निर्धारित करने। हम अपने कॉल अक्षम setAutoGrow करने के लिए() और approrpriate समय पर setSize() कॉल के बारे में सतर्क रहने के लिए होगा। , क्योंकि वे 'IFRAME' का उपयोग कर रहे iframe के बजाय उनके पार में https://developers.facebook.com/bugs/228704057203827
आप कर रहे हैं यह सही कर रहा है, आपको इनमें से किसी की आवश्यकता नहीं है। – Bob