diff --git a/resources/gd-custom.js b/resources/gd-custom.js index ae5bba3b..ae07cf31 100644 --- a/resources/gd-custom.js +++ b/resources/gd-custom.js @@ -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); + } + }); })($_$); @@ -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); -} + diff --git a/website.cc b/website.cc index 39b1adce..d7048cc0 100644 --- a/website.cc +++ b/website.cc @@ -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;\">" "";