Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

delphi EmbeddedWB iframe height issue

i have few webpages in MySQL database, that I want to show as "slideshow" on my Delphi (7) form. I am trying to use EmbeddedWebBrowser for it, and generating my HTML file dynamically, using iframe tags - for showing more than 1 webpage at the moment.

the problem is, when i load this html file into EmbeddedWB, the height is only around 150px, however in IE, FF, chrome looks OK.

My Delphi code:

embeddedwb1.LoadFromFile('mypage.html');

any suggestions?

PS: the webpages from my collection aren't from same domain.

how to reproduce: Place an Embeddedwebbrowser component to form, set

RegisterAsBrowser

parameter to

True

, for "silent" mode i added this Event to EmbeddedWebBrowser:

procedure TForm1.EmbeddedWB1ScriptError(Sender: TObject; ErrorLine, ErrorCharacter, ErrorCode, ErrorMessage, ErrorUrl: String; var ContinueScript, Showdialog: Boolean); 
    begin 
    continuescript:=true;
    showdialog:=false; 
    end;

then I generated with a simple for... loop html code shown above.. If mypage website in has "child" iframe, it's not showing correctly the child iframe height (from another domain).. If this ads.html file (generated by this simple delphi app) is opened in normal IE (11) , it showing child iframe correctly... I tried to change embeddedwebbrowser parameters (there are a lot of them) , but without success.. Sorry for this "full working example" - i need to learn how to write with better quality, but 1) my english is not good 2) i am new here, must learn a lot :) but this problem is almost critical, i must solve it till wednesday i placed one button to form1 , the form doing the following:

embeddedwb1.LoadFromFile('mypage.html');

example of 'mypage.html':

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=11"></head>
<body>
<iframe style="position:absolute;width:100%;height:100%" src="http://www.expresspaid.net/?x=ptcview&amp;view=bHNETmxjTXd1ck4wQWxYWmx6YWRkS0xSWGVZSklWSlJ3aWVOdzVkOXNhND0,">
</iframe>
</body>
</html>

UPDATE

AFTER ONE WEEK OF GOOGLING I FIXED THIS PROBLEM! :)

the solution was:

when i generated .html file from Delphi (wrote whole code dynamically to textfile and then opened in EmbeddedWB)
I wrote iframe tag like this:

htmlpage:=htmlpage+`'<iframe width="100%" height="800" src="'+mypagestring+'"></iframe>'+#13+#10;

but it was not good..

my new and working html tag:

htmlpage:=htmlpage+'<iframe sandbox="allow-same-origin allow-scripts allow-popups allow-forms" width="100%" height="800" src="+mypagestring+"></iframe>'+#13+#10;

as You see, usage of sandbox in parent iframe helped me to show full child iframe, not only a piece of that :)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...