diff --git a/apps/routerconsole/jsp/i2ptunnelmgr.jsp b/apps/routerconsole/jsp/i2ptunnelmgr.jsp index f47f41147b8752a38b176ae9d3807c84246a0e15..b459476334dd6a3dba9a6bacb4ce3b97d0d4c93b 100644 --- a/apps/routerconsole/jsp/i2ptunnelmgr.jsp +++ b/apps/routerconsole/jsp/i2ptunnelmgr.jsp @@ -50,7 +50,31 @@ // but does not include the margin. Therefore, any content within the iframe // should have no margins at the very top or very bottom to avoid a scrollbar. var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document; - f.style.height = doc.body.offsetHeight + "px"; + var totalHeight = doc.body.offsetHeight; + + // Detect if horizontal scrollbar is present, and add its width to height if so. + // This prevents a vertical scrollbar appearing when the min-width is passed. + // FIXME: How to detect horizontal scrollbar in iframe? Always apply for now. + if (true) { + // Create the measurement node + var scrollDiv = document.createElement("div"); + scrollDiv.className = "scrollbar-measure"; + scrollDiv.style.width = "100px"; + scrollDiv.style.height = "100px"; + scrollDiv.style.overflow = "scroll"; + scrollDiv.style.position = "absolute"; + scrollDiv.style.top = "-9999px"; + document.body.appendChild(scrollDiv); + + // Get the scrollbar width + var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; + totalHeight += scrollbarWidth; + + // Delete the div + document.body.removeChild(scrollDiv); + } + + f.style.height = totalHeight + "px"; } function setupFrame() { f = document.getElementById("i2ptunnelframe"); diff --git a/apps/routerconsole/jsp/torrents.jsp b/apps/routerconsole/jsp/torrents.jsp index e029a48cd6b5c7e036d239e61924935d1b11f906..665f0398524c474f33600f64a6a30ccc738a53de 100644 --- a/apps/routerconsole/jsp/torrents.jsp +++ b/apps/routerconsole/jsp/torrents.jsp @@ -32,7 +32,31 @@ // but does not include the margin. Therefore, any content within the iframe // should have no margins at the very top or very bottom to avoid a scrollbar. var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document; - f.style.height = doc.body.offsetHeight + "px"; + var totalHeight = doc.body.offsetHeight; + + // Detect if horizontal scrollbar is present, and add its width to height if so. + // This prevents a vertical scrollbar appearing when the min-width is passed. + // FIXME: How to detect horizontal scrollbar in iframe? Always apply for now. + if (true) { + // Create the measurement node + var scrollDiv = document.createElement("div"); + scrollDiv.className = "scrollbar-measure"; + scrollDiv.style.width = "100px"; + scrollDiv.style.height = "100px"; + scrollDiv.style.overflow = "scroll"; + scrollDiv.style.position = "absolute"; + scrollDiv.style.top = "-9999px"; + document.body.appendChild(scrollDiv); + + // Get the scrollbar width + var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; + totalHeight += scrollbarWidth; + + // Delete the div + document.body.removeChild(scrollDiv); + } + + f.style.height = totalHeight + "px"; } function setupFrame() { f = document.getElementById("i2psnarkframe");