diff --git a/apps/routerconsole/jsp/i2ptunnelmgr.jsp b/apps/routerconsole/jsp/i2ptunnelmgr.jsp
index dc388f28c25b7d183f0e0dce9d1dd602d0c29f6c..5db19465ffab8002a5bf454fd10613770af7e722 100644
--- a/apps/routerconsole/jsp/i2ptunnelmgr.jsp
+++ b/apps/routerconsole/jsp/i2ptunnelmgr.jsp
@@ -21,16 +21,20 @@
   var failMessage = "<hr><b><%=intl._("Router is down")%><\/b>";
   function requestAjax1() { ajax("/xhr1.jsp?requestURI=<%=request.getRequestURI()%>", "xhr", <%=intl.getRefresh()%>000); }
   function initAjax() { setTimeout(requestAjax1, <%=intl.getRefresh()%>000);  }
+  function injectClass(f) {
+      f.className += ' iframed';
+      var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document;
+      doc.body.className += ' iframed';
+      doc.getElementsByClassName('panel')[0].className += ' iframed';
+  }
   function resizeFrame(f) {
-      var body = f.contentWindow.document.body,
-          html = f.contentWindow.document.documentElement;
-      f.style.height = body.scrollHeight + "px";
+      var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document;
+      f.style.height = doc.body.offsetHeight + "px";
   }
-  function injectClass(f) { f.contentWindow.document.body.setAttribute('class', 'iframed'); }
   function setupFrame() {
       f = document.getElementById("i2ptunnelframe");
-      resizeFrame(f);
       injectClass(f);
+      resizeFrame(f);
   }
 </script>
 </head><body onload="initAjax()">
diff --git a/apps/routerconsole/jsp/torrents.jsp b/apps/routerconsole/jsp/torrents.jsp
index 690be49a5a5d216c24384b8bede89140f2eb59ad..ed052ace0c3bc37ba13ca5d84c852d80c76472dd 100644
--- a/apps/routerconsole/jsp/torrents.jsp
+++ b/apps/routerconsole/jsp/torrents.jsp
@@ -21,12 +21,19 @@
   var failMessage = "<hr><b><%=intl._("Router is down")%><\/b>";
   function requestAjax1() { ajax("/xhr1.jsp?requestURI=<%=request.getRequestURI()%>", "xhr", <%=intl.getRefresh()%>000); }
   function initAjax() { setTimeout(requestAjax1, <%=intl.getRefresh()%>000);  }
-  function resizeFrame(f) { f.style.height = f.contentWindow.document.body.scrollHeight + "px"; }
-  function injectClass(f) { f.contentWindow.document.body.setAttribute('class', 'iframed'); }
+  function injectClass(f) {
+      f.className += ' iframed';
+      var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document;
+      doc.body.className += ' iframed';
+  }
+  function resizeFrame(f) {
+      var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document;
+      f.style.height = doc.body.offsetHeight + "px";
+  }
   function setupFrame() {
       f = document.getElementById("i2psnarkframe");
-      resizeFrame(f);
       injectClass(f);
+      resizeFrame(f);
   }
 </script>
 </head><body onload="initAjax()">