mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
opt:iframe height auto resize
some website ,the page content is lazy load, the iframe-resizer seems has trouble with them.
This commit is contained in:
parent
19378d2f83
commit
6e74c27ea2
|
@ -46,9 +46,9 @@ void IframeSchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob)
|
|||
|
||||
QString baseTagHtml = "<base href=\"" + base + "\">";
|
||||
|
||||
QString depressionFocus =
|
||||
QStringLiteral( "<script type=\"application/javascript\">HTMLElement.prototype.focus=function(){console.log(\".focus has been depressed \");}</script>"
|
||||
"<script type=\"text/javascript\" src=\"qrc:///scripts/iframeResizer.contentWindow.min.js\"></script>");
|
||||
QString depressionFocus ="<script type=\"application/javascript\"> HTMLElement.prototype.focus=function(){console.log(\"focus() has been disabled.\");}</script>"
|
||||
"<script type=\"text/javascript\" src=\"qrc:///scripts/iframeResizer.contentWindow.min.js\"></script>"
|
||||
"<script type=\"text/javascript\" src=\"qrc:///scripts/iframe-defer.js\"></script>";
|
||||
|
||||
// remove existed base tag
|
||||
articleString.remove( baseTag ) ;
|
||||
|
|
|
@ -5,5 +5,6 @@
|
|||
<file>scripts/gd-builtin.js</file>
|
||||
<file>scripts/gd-custom.js</file>
|
||||
<file>scripts/jquery-3.6.0.slim.min.js</file>
|
||||
<file>scripts/iframe-defer.js</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
});
|
||||
|
||||
//monitor iframe height.
|
||||
$('iframe').iFrameResize({ checkOrigin:false,maxHeight :800,scrolling:true,warningTimeout:0,minHeight :250,log:true});
|
||||
$('iframe').iFrameResize({ checkOrigin:false,maxHeight :800,scrolling:true,warningTimeout:0,minHeight :250,log:true,autoResize:false});
|
||||
});
|
||||
})($_$);
|
||||
|
||||
|
|
13
scripts/iframe-defer.js
Normal file
13
scripts/iframe-defer.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
setInterval(function () {
|
||||
//in some cases ,the website in iframe will load result after document has been loaded. the height will continue to change.
|
||||
const body = document.body;
|
||||
const html = document.documentElement;
|
||||
|
||||
const height = Math.max(body.scrollHeight, body.offsetHeight,
|
||||
html.clientHeight, html.scrollHeight, html.offsetHeight);
|
||||
|
||||
if ('parentIFrame' in window) {
|
||||
console.log("iframe set height to " + height);
|
||||
parentIFrame.size(height);
|
||||
}
|
||||
}, 500);
|
Loading…
Reference in a new issue