Skip to content

Commit

Permalink
fix: qt6.2 iframe can not access gdlookup built-in javascript
Browse files Browse the repository at this point in the history
it throw CORS exception in the devtool console  windows.
  • Loading branch information
xiaoyifang committed Apr 17, 2022
1 parent 15702d8 commit 376f0f1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
35 changes: 22 additions & 13 deletions resources/gd-custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,27 @@ $(function() {

});

//monitor iframe height.

$( "iframe" ).on( "load", function() {
var iframe = $( this );
resizeIframe( iframe[ 0 ] );
} );

function resizeIframe(obj) {
setInterval(function(){
//in some cases ,the website in iframe will load result after document has been loaded. the height will continue to change.
if($(obj).contents().height() <2000)
{
$(obj).height($(obj).contents().height());
}
else{
$(obj).height(2000);
obj.scrolling="yes";
}
},500);
}

});
})($_$);

Expand All @@ -52,16 +73,4 @@ function playSound(sound) {
a.play();
}

function resizeIframe(obj) {
setInterval(function(){
//in some cases ,the website in iframe will load result after document has been loaded. the height will continue to change.
if(obj.contentWindow.document.documentElement.scrollHeight <1000)
{
obj.style.height = obj.contentWindow.document.documentElement.scrollHeight + 'px';
}
else{
obj.style.height ='1000px'
obj.scrolling="yes";
}
},500);
}

2 changes: 1 addition & 1 deletion website.cc
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ sptr< DataRequest > WebSiteDictionary::getArticle( wstring const & str,
"\" onmouseover=\"processIframeMouseOver('gdexpandframe-" + getId() + "');\" "
"onmouseout=\"processIframeMouseOut();\" "
"scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" "
"frameborder=\"0\" vspace=\"0\" hspace=\"0\" onload=\"resizeIframe(this)\""
"frameborder=\"0\" vspace=\"0\" hspace=\"0\""
"style=\"overflow:visible; width:100%; display:block;\">"
"</iframe>";

Expand Down

0 comments on commit 376f0f1

Please sign in to comment.